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-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/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
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-venv
or 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.
Reinstalling didn't work. I will close this issue now. I will update if I have any more information.
@animeshb , you don't have more output after
Failing command: ['/home/float/test/t/bin/python3.6', '-Im', 'ensurepip', '--upgrade', '--default-pip']
?
float@animesh:~/test$ python3.6 -m venv venv
Nothing after that line.
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/float/test/t/bin/python3.6', '-Im', 'ensurepip', '--upgrade', '--default-pip']
In the venv/bin
folder, it doesn't have activate command.
float@animesh:~/test$ ls venv/bin/
python python3 python3.6
I can only redirect you to one of many pages matching this error (it's a known prob with debian/ubuntu systems):
https://bugs.launchpad.net/ubuntu/+source/python3.4/+bug/1290847
what about sudo apt-get install python3-pip
?
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:
$ docker run --rm -it debian:buster /bin/bash
$ apt update
...
$ apt install python3.5 python3.6 python3.5-venv
...
$ python3.6 -m venv venv
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: ['/venv/bin/python3.6', '-Im', 'ensurepip', '--upgrade', '--default-pip']
$ rm -rf venv
$ apt install python3.6-venv
...
$ python3.6 -m venv venv
... success
Install 'python3.6-venv', and it should work.
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.
The solution by @eukaryote worked for me. Thanks for posting this!
Wrongly configured locale can also induce this problem, as this answer solves my problem that produces the same error message as OP.
Try execute:
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales
only one datapoint, but messing about with a fresh virtualbox ubuntu bionic, i found that apt install python3.6-venv
still left me with a broken python3.6 -m venv
, but running apt install python3-venv
fixed it.
I'm on Debian testing/buster and I'm having this same issue, while both python3.6-venv
and python3-venv
are both installed.
The debian bug for this is here btw: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901601
nikolas
They write there that it is repaired in the last version. So I made
apt purge python3.6-venv
dpkg -i --force-depends-version python3.6-venv_3.6.6~rc1-3_amd64.deb # from snapshot.debian.org
and it works for me.
Probably I will need fix later: apt --fix-broken install
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 is apt-get install python3.7-venv
Just FYI, the above solution does not in fact work for python 3.7. apt install python3.7 python3.7-venv
on a stock buster docker image still produces a broken virtualenv ("ensurepip is not available"). However, after apt 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, with python3.7 -m venv myvenv
. So the complete working command set is this:
sudo apt install python3.7 python3-venv python3.7-venv # all three are required
python3.7 -m venv myvenv
. myvenv/bin/activate
(btw, note that all python3.7-venv
installs is a dummy system ensurepip
module.)
you're talking about venv
, which is a different project. This tracker is for virtualenv.
I was also facing the same issue.
[niraj@abc ~]$/python/v3.7.0/bin/python3 -m venv avd
Error: Command '['/home/niraj/avd/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
After adding libffi3.3 on my LD_LIBRARY path it works
setenv LD_LIBRARY_PATH /libffi/v3.3/lib64
Fisrt I've installed with sudo apt install python3-venv
and had the same problem and, it was solved by doing: sudo apt install python3.6-venv
@eukaryote still didn't work. Can you help? I am on Ubuntu 18.04 LTS
Wrongly configured locale can also induce this problem, as this answer solves my problem that produces the same error message as OP.
Try execute:
export LC_ALL="en_US.UTF-8" export LC_CTYPE="en_US.UTF-8" sudo dpkg-reconfigure locales
This work for me on Ubuntu 16.04.6. Thx
Wrongly configured locale can also induce this problem, as this answer solves my problem that produces the same error message as OP.
Try execute:
export LC_ALL="en_US.UTF-8" export LC_CTYPE="en_US.UTF-8" sudo dpkg-reconfigure locales
thank you
Wow, installing the specific version of venv worked for me. In my case python3.8-venv.
Thanks @jrperin
Installing the specific version worked for me too: python3.8-venv
If OS version is 18.04 or 20.04:
sudo apt remove python3.6
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.6
sudo apt install python3.6-venv
sudo apt install python3.6-dev
Additional Supporting Softwares
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
Most helpful comment
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.