I am using the Ubuntu on Windows App running on Windows Subsystem for Linux. So an initial question is if Python virtual environments is supported. Given my as yet limited understanding of Python virtual environments I would think that they are supported in the Ubuntu on Windows App. Here is the version info:
Windows Ubuntu App 1804.2019.521.0
Ubuntu release 18.04 (bionic)
Python Version 3.6.7 (as best I remember this was installed by default).
My motivation for wanting to use venv
is this reddit post:
venv by nature of being part of Python itself has access to the internals of Python which means it can do things the right way with far fewer hacks... ...So venv can be thought of virtualenv done right, with the blessing and support of the Python developers.
Similar questions came up when I entered my question, but I didn't find one that solved my problem.
One post:
Since you specifically installed
python3.6
instead of Ubuntu's defaultpython3
version, which ispython3.5
, you have to installpython3.6-venv
instead ofpython3-venv
since that would resolve topython3.5-venv
. To do so, you can usesudo apt install python3.6-venv
Another post from 01/2018 said that python3.6 -m venv myvenv
worked after reinstalling Python3.6.4. I'm avoiding re-installation for the time being.
Here is what I tried to create a virtual environment:
1) Opened Ubuntu
2) Went to the directory where I want to create the virtual environment.
/home/dgrucza/python-virtual-environments
3) Entered python3 -m venv env
This returned the following:
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.
Failing command: ['/home/dgrucza/python-virtual-environments/evn/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']
4)Tried to install venv by entering sudo apt-get install python-venv
After entering my password at the prompt this returned the following:
Reading package lists... Done Building dependency tree Reading state information... Done Package python3-venv is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
E: Package 'python3-venv' has no installation candidate
5) Also tried entering python3.6 -m venv myenv
, but received the same message.
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.
Failing command: ['/home/dgrucza/myenv/bin/python3.6', '-Im', 'ensurepip', '--upgrade', '--default-pip']
python3-venv
. I don't expect any problems or conflicts/confusions if you don't have any custom Python versions installed. So do you have that already and it doesn't work? If so, please provide what exactly happens instead, like complete output and error messages.sudo add-apt-repository universe
and got this response:'universe' distribution component is already enabled for all sources.