Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating virtualenv with Python3

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))
like image 931
Xar Avatar asked Jun 09 '17 10:06

Xar


2 Answers

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
like image 169
codelessbugging Avatar answered Oct 21 '22 04:10

codelessbugging


For venv and python3.6 installing venv one can use below to fix the issue

sudo apt install python3.6-venv

like image 42
v.c Avatar answered Oct 21 '22 04:10

v.c