Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating virtualenv with python3.6 #1059

Closed
anmsh opened this issue Jun 22, 2017 · 24 comments
Closed

Error creating virtualenv with python3.6 #1059

anmsh opened this issue Jun 22, 2017 · 24 comments

Comments

@anmsh
Copy link

anmsh commented Jun 22, 2017

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
@gst
Copy link

gst commented Jul 4, 2017

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.

@anmsh
Copy link
Author

anmsh commented Jul 6, 2017

Reinstalling didn't work. I will close this issue now. I will update if I have any more information.

@anmsh anmsh closed this as completed Jul 6, 2017
@gst
Copy link

gst commented Jul 6, 2017

@animeshb , you don't have more output after

Failing command: ['/home/float/test/t/bin/python3.6', '-Im', 'ensurepip', '--upgrade', '--default-pip']

?

@anmsh
Copy link
Author

anmsh commented Jul 6, 2017

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

@gst
Copy link

gst commented Jul 7, 2017

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 ?

@eukaryote
Copy link

eukaryote commented Jul 8, 2017

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.

@anmsh
Copy link
Author

anmsh commented Jul 8, 2017

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.

@Sedlacekj
Copy link

The solution by @eukaryote worked for me. Thanks for posting this!

@z11i
Copy link

z11i commented Feb 17, 2018

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

@hjwp
Copy link

hjwp commented May 30, 2018

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.

@nikolas
Copy link

nikolas commented Jun 18, 2018

I'm on Debian testing/buster and I'm having this same issue, while both python3.6-venv and python3-venv are both installed.

@nikolas
Copy link

nikolas commented Jun 18, 2018

The debian bug for this is here btw: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901601

@zvolsky
Copy link

zvolsky commented Jun 22, 2018

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

@karolyi
Copy link

karolyi commented Oct 23, 2018

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

@garyo
Copy link

garyo commented Oct 30, 2018

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.)

@gaborbernat
Copy link
Contributor

you're talking about venv, which is a different project. This tracker is for virtualenv.

@npandey2385
Copy link

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

@jrperin
Copy link

jrperin commented Dec 29, 2018

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

@soopyc
Copy link

soopyc commented Apr 15, 2019

@eukaryote still didn't work. Can you help? I am on Ubuntu 18.04 LTS

@newtonjose
Copy link

newtonjose commented May 25, 2019

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

@ghost
Copy link

ghost commented Sep 13, 2019

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

@johntovor
Copy link

Wow, installing the specific version of venv worked for me. In my case python3.8-venv.

Thanks @jrperin

@wkolcz-UMHS
Copy link

Installing the specific version worked for me too: python3.8-venv

@jariojose
Copy link

jariojose commented Jul 25, 2020

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

@pypa pypa locked and limited conversation to collaborators Jul 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests