virtualenv: Error creating virtualenv with python3.6
Earlier today I installed python3.6 on my debian machine. Python3.6 was made available in buster distribution. When I try to create a virtualenv with python3.6.
python3.6 -m venv venv
gives the following error.
The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the
python3-venvpackage 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/float/test/t/bin/python3.6’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]
I do have python3-venv (3.5.3-1) installed. Why do I get this error? If I run the command
py3 -Im ensurepip --upgrade --default-pip
it says
/usr/bin/python3.6: No module named ensurepip
I don’t have trouble creating virtualenvs using the default python3 version (3.5.3).
Also , I noticed that I can create a virtualenv as follows:
virtualenv -p python3.6 venv
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 5
- Comments: 24 (1 by maintainers)
The original poster’s problem is due to not having the ‘python3.6-venv’ package installed, which can be verified using Docker if you don’t have access to a buster Debian:
Install ‘python3.6-venv’, and it should work.
Wrongly configured locale can also induce this problem, as this answer solves my problem that produces the same error message as OP.
Try execute:
Hi,
virtualenv and python3 venv own module are 2 totally different projects/things.
venv is doing the same than virtualenv but is directly integrated in python3 itself. virtualenv is the historic project basically (and normally should not be used with python3 while there is venv).
Based on your input I’d say python3-venv may be to reinstall (
sudo apt-get reinstall python-venvor something similar) on your side. But I can be wrong. Anyway this looks like all debian related I’m pretty sure.So may you close the issue ? (I’m not maintainer here) regards.
Wow, it didn’t occur to me at all that there would be a version specific -venv package. Installing this did the trick.
@gst and @eukaryote Thank you so much for spending your time on this issue.
Just leaving a comment here, for the ones who arrive after me, googling for the same problem:
the same applies to 3.7 of python, you have to install
python3.7-venv, that isapt-get install python3.7-venvJust FYI, the above solution does not in fact work for python 3.7.
apt install python3.7 python3.7-venvon a stock buster docker image still produces a broken virtualenv (“ensurepip is not available”). However, afterapt install python3-venv(which needlessly installs all of python3.6), you can create a working python 3.7 venv including a proper 3.7 pip, withpython3.7 -m venv myvenv. So the complete working command set is this:(btw, note that all
python3.7-venvinstalls is a dummy systemensurepipmodule.)I’m on Debian testing/buster and I’m having this same issue, while both
python3.6-venvandpython3-venvare both installed.Fisrt I’ve installed with
sudo apt install python3-venvand had the same problem and, it was solved by doing:sudo apt install python3.6-venvWow, installing the specific version of venv worked for me. In my case python3.8-venv.
Thanks @jrperin
only one datapoint, but messing about with a fresh virtualbox ubuntu bionic, i found that
apt install python3.6-venvstill left me with a brokenpython3.6 -m venv, but runningapt install python3-venvfixed it.The debian bug for this is here btw: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901601