Executed below 2 commands and then I was able to install the packages.
sudo apt update sudo apt install python3-pip
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
sudo apt-get install dos2unix
and it installed properly.
The error you’re getting is because “atom” isn’t part of the default packages, but WSL does not support graphical applications like Atom so it would never work anyway.
I would recommend installing it for Windows which is available from their website atom.io.
To make sure a package is actually in the package system you can use
apt search <whatever> or for a simpler output
apt-cache search <whatever>.
NOTE: Do not do the following, but for completeness sake I’ll add how to actually install it:
You need to add the atom repository with the following command:
sudo add-apt-repository ppa:webupd8team/atom
After that you can install it by first updating the search cache with
apt-get update and then installing the package with
apt-get install atom.
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.
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.
What was working for me:
wsl --set-version Ubuntu-18.04 2
wsl --set-version Ubuntu-20.04 2
This fixed it perfectly for me:
Reposting incase the link ever dies:
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.
Delete the default /etc/resolv.conf file.
sudo rm /etc/resolv.conf
Create a new /etc/resolv.conf with the following entry.
Now, restart the WSL2 and open the distro again. The apt update on WSL2 should work like a charm.
Usually only updates packages is needed before:
sudo apt update