Error creating virtualenv with Python3

Xar picture Xar · Jun 9, 2017 · Viewed 14.2k times · Source

I'm working on Linux Mint 17 and I'm trying to create a new virtualenv with Python3 like this:

python3.6 -m venv env

And this is the error that I get:

Error: Command '['/home/ric/myprojs/django-example-channels/env/bin/python3.6', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

I've googled this error message but haven't managed to find anything too informative.

This is my pip version, in case it make any difference:

pip --version
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)

I've been using Python2 for some time, but I'm new to Python3. I don't know what I may be missing.

UPDATE 1:

Answering @cezar's question, when I type  which python3 this is what I get:

$ which python3
/usr/bin/python3

UPDATE 2:

Answering @Chłop Z Lasu:

$ virtualenv -p python3.6 env
Running virtualenv with interpreter /usr/bin/python3.6
Using base prefix '/usr'
New python executable in /home/ric/myprojs/django-example-channels/example_channels/env/bin/python3.6
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2328, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 713, in main
    symlink=options.symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 925, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1231, in install_python
    shutil.copyfile(executable, py_executable)
  File "/usr/lib/python3.6/shutil.py", line 104, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))

Answer

codelessbugging picture codelessbugging · Jun 12, 2017

The error indicates that virtualenv is trying to make an environment in your python path. therefore, you have to specify your virtualenv destination

virtualenv -p python3.6 /path/to/yourenv