17

I'm trying to use python3.6 -m venv test directly in PythonAnywhere to create a virtualenv. I wanted to use this method as I believe it is more portable to other environments where virtualenvwrapper might not be set up.

When I run the command (in a PA environment that has been upgraded to use Python 3.6) I get the following error.

12:34 ~ $ python3.6 -m venv test
Error: Command '['/home/dpottsagilisys/test/bin/python3.6', '-Im', 'ensurepip', 
'--upgrade', '--default-pip']' returned non-zero exit status 1.
Dave Potts
  • 1,543
  • 2
  • 22
  • 33

2 Answers2

31

PythonAnywhere dev here: this appears to be a bug in Ubuntu 14.04 (and apparently 15.04), which we were based on when this question was originally asked.

This Ask Ubuntu question has various suggestions; here's one that I've made 100% certain works on PythonAnywhere:

python3.6 -m venv --without-pip test
source test/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python
deactivate
source test/bin/activate

[Update 28 June 2018: Switching to a 16.04 image is, coincidentally, what we're working on right now.]

[Update 30 September 2018: the 16.04 image is now live for new PythonAnywhere accounts]

Giles Thomas
  • 6,039
  • 2
  • 33
  • 51
  • 2
    Thanks! I got the same error on Fedora 26 and this workaround helped – Michael Clerx Dec 07 '17 at 08:39
  • 1
    "curl https://bootstrap.pypa.io/get-pip.py | python" produced a 403 proxy error when I tried it. Worked around it by pasting the get-pip.py into a file on github, then 'pull'ing the file down and running it. – Inyoka Dec 07 '17 at 10:50
12

Not having the package python3.6-venv causes this issue. Installing with:
sudo apt-get install python3.6-venv should resolve.

anOkCoder
  • 353
  • 5
  • 11