50

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.

Devoloper250
  • 1,559

7 Answers7

70

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/

MMM
  • 3,257
Devoloper250
  • 1,559
11

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.

11

This fixed it perfectly for me: https://sundarnarasiman.net/2021/05/15/wsl2-apt-update-not-working/

Reposting incase the link ever dies:

Step #1.

On the Ubuntu distro, create a file at this location /etc/wsl.conf.

The file should have the following configuration.

[network]
generateResolvConf = false

If we don’t set this file, WSL will automatically load a default /etc/resolv.conf with default namesever configuration.

Shut down and restart the distro.

Step #2

Delete the default /etc/resolv.conf file.

sudo rm /etc/resolv.conf

Create a new /etc/resolv.conf with the following entry.

nameserver 8.8.8.8

Now, restart the WSL2 and open the distro again. The apt update on WSL2 should work like a charm.

1

What was working for me:

wsl --set-version Ubuntu-18.04 2

or

wsl --set-version Ubuntu-20.04 2
ZygD
  • 2,577
0

Same error, solved after:

sudo vi /etc/apt/sources.list # add source
sudo apt update # update source cache

My sources.list file:

deb http://mirrors.163.com/ubuntu/ bionic main restricted
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted
deb http://mirrors.163.com/ubuntu/ bionic universe
deb http://mirrors.163.com/ubuntu/ bionic-updates universe
deb http://mirrors.163.com/ubuntu/ bionic multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted
deb http://security.ubuntu.com/ubuntu/ bionic-security universe
deb http://security.ubuntu.com/ubuntu/ bionic-security multiverse

Edit this list according to your location, as some sources may not apply globally.

Qinsi
  • 111
0

Easiest solution for Non GUI packages installation in a fresh WSL

Just run the below commands in the terminal:

sudo apt-get update

sudo apt-get install your-package-name

The error is generally observed when you have a fresh WSL configuration on windows. Thus, you need to update your apt-get package manager. However, as mentioned above, for packages that involve a GUI (Atom), it isnt supported by WSL out of the box.

-1

Usually only updates packages is needed before:

sudo apt update
TOUDIdel
  • 107