apt-get install is not working in WSL

99,602

Solution 1

Executed below 2 commands and then I was able to install the packages.

sudo apt update    
sudo apt install python3-pip

Source - https://linuxize.com/post/how-to-install-pip-on-ubuntu-18.04/

Solution 2

System: Windows 10 Enterprise, Ubuntu Windows Subsystem for Linux.

I ran this command:

sudo apt-get install dos2unix

I had this error:

E: Unable to locate package dos2unix

I then ran:

sudo apt-get update

and then:

sudo apt-get install dos2unix

and it installed properly.

Share:
99,602

Related videos on Youtube

Devoloper250
Author by

Devoloper250

Updated on September 18, 2022

Comments

  • Devoloper250
    Devoloper250 over 1 year

    Windows 10 Ubuntu bash failing to install packages. Whenever I try install new package with below command, getting same error.

    root@VASI-HOME-PC:/mnt/c/Users/vadap# apt-get install atom
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package atom
    

    This is not just with atom pacakge but i tried installing other packages like pip as well and received same error.

    • Ramhound
      Ramhound over 5 years
      The error message you received, indicates Atom is required, which means the package you are trying to install has a GUI. That isn't going to be supported by WSl out of the box. In other words, you are not going to be able to install any package, that requires Atom.
    • Devoloper250
      Devoloper250 over 5 years
      @Ramhound I have tried to install pip and few other packages. I have received the same error. Does it mean all of them had GUI ?
    • Willman
      Willman over 3 years
      I'm having this issue on WSL2 Debian 10, trying to install openssh-server as root user. I think the issue the OP had was that he was invoking apt as the root user, and not sudoing from an unprivileged user. I'm not sure why, but apt only works when you run it with sudo from a non-root user...
  • Ramhound
    Ramhound over 5 years
    This answer is unlikely to be well recieved, unless you provide the relevant information from the link, like what you actually did in the body of the answer.
  • Devoloper250
    Devoloper250 over 5 years
    Thank you @Ramhound . I have updated the steps executed and later I was able to install the packages like pip.
  • Scott - Слава Україні
    Scott - Слава Україні almost 5 years
    What did you add to the sources.list file? Please do not respond in comments; edit your answer to make it clearer and more complete.
  • Qinsi
    Qinsi almost 5 years
    @Scott File content added ;D
  • Timo
    Timo over 3 years
    After update do apt upgrade to be updated.
  • NotTheDr01ds
    NotTheDr01ds almost 3 years
    This is exactly the same thing that the accepted answer already says. Do you have additional information to add?
  • Admin
    Admin almost 2 years
    I just sudo apt update followed by sudo apt upgrade like Timo said and that was enough for me to get it to work.