I was working with virtual environments with Ubuntu 18.04 LTS but I uninstalled it and installed Ubuntu 20.04 LTS on windows 10, but now when I create venv
then error is
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt-get install python3-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
when I install sudo apt-get install python3-venv
it say installed but still struggling badly
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-venv is already the newest version (3.8.2-0ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5
Answers
I found a solution to this problem: The mounted drive I was creating the venv directory in was owned by root. If you think this might be the cause, try creating a venv in your Ubuntu LTS home directory. You should be able to create it there.
From within my project’s directory, I ended up using chown recursively with this command:
Note that you might not want to do this on the whole drive, so be careful where you do this with recursive commands.
Here are the basic instructions for setting up a brand new Python 3.8 environment, except right before I made the venv, I made sure to be the owner of the directory:
https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-an-ubuntu-20-04-server
Note: A more correct way of doing it might be to change the mounting options of drives using the wsl.conf instructions here, but it didn’t seem to help when I tried: https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/
Other things I did before I stumbled upon this:
Other notes for Python 3.8 in Ubuntu 20.04, for problems I experienced directly after activating my new venv which might not apply to you:
pip install wheel
so that commands likepip install jupyter
do not have errors.I had the same issue on Ubuntu 20.04 WSL2 Win10 build 2004, when trying to make virtual environment on D: drive which is /mnt/d [NTFS]. I was able to solve it with below commands by unmounting and remounting with metadata
After going through Phy6’s Answer, I just tried running it as sudo and it worked.
I’m a bit late, By default, 20.0.4 ships with python3.8
if you’re specifically looking to install virtualenv for other version’s, try installing the version and retry.
eg: for python3.6
and to create a virutalenv
For me, this issue happened because I was trying to create a virtual environment using another virtual environment. "venv-ception"
I solved by:
i.e.