9

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))
Xar
  • 7,572
  • 19
  • 56
  • 80
  • 1
    You run `python3.6` from your virtual environment. In Linux Mint 17 `python3` is installed per default and should be available under `/usr/bin/python3`. What happens if you do `which python3`? – cezar Jun 09 '17 at 11:10
  • 1
    Your question is about the python standard library module `venv` (https://docs.python.org/3/library/venv.html). That is not the same as `virtualenv` (https://pypi.python.org/pypi/virtualenv). Maybe you should edit the tags to reflect this. – cezar Jun 09 '17 at 11:13
  • I just edited my question @cezar – Xar Jun 09 '17 at 11:14
  • 1
    Possible duplicate of [Using Python 3 in virtualenv](https://stackoverflow.com/questions/23842713/using-python-3-in-virtualenv) – ivan_pozdeev Jun 09 '17 at 11:45
  • 2
    By the way, `pip3 --version` is what you should check, notice that output is Python2 – OneCricketeer Jun 12 '17 at 16:11

4 Answers4

21

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
codelessbugging
  • 2,849
  • 1
  • 14
  • 19
4

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

sudo apt install python3.6-venv

v.c
  • 126
  • 1
  • 5
-2

You gotta install the venv via code bellow:

sudo apt install python3.6-venv

-2

Expanding on the Answer Above:

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

Since -p is a flag equivalent to --python, you can also use.

$ virtualenv --python=python3.6 /path/to/yourenv

Or

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