Passing Python3 to virtualenvwrapper raises ImportError

I am trying to use virtualenvwrapper to create python 3 virtualenv based. However, when I pass an optional argument to the interpreter, I see this error. I am running Ubuntu 15.04. I tried reinstalling virtualenv and virtualenvwrapper without success. Thank you for your help!

 $ mkvirtualenv scriptcutter --python=/usr/bin/python3 Running virtualenv with interpreter /usr/bin/python3 Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module> import base64 File "/usr/lib/python3.4/base64.py", line 9, in <module> import re File "/usr/lib/python3.4/re.py", line 336, in <module> import copyreg File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module> raise ImportError('This package should not be accessible on Python 3. ' ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted. Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook if not enabled(): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled import re File "/usr/lib/python3.4/re.py", line 336, in <module> import copyreg File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module> raise ImportError('This package should not be accessible on Python 3. ' ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted. Original exception was: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module> import base64 File "/usr/lib/python3.4/base64.py", line 9, in <module> import re File "/usr/lib/python3.4/re.py", line 336, in <module> import copyreg File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module> raise ImportError('This package should not be accessible on Python 3. ' ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted. 
+5
source share
3 answers

This is a workaround so far.

Create virtualenv with pyvenv .

 # install pyvenv on Ubuntu sudo apt-get install python3-venv 

To minimize disruption in your normal workflow, pass in the destination directory that matches the one used by virtualenvwrapper Also,

pyvenv example ~/.virtualenvs/example

This automatically works with the workon and cdproject . I do not use much else that is provided by virtualenvwrapper

Hope this helps.

+2
source

I ran into the same problem, but after I downgraded virtualenv to 12.0.2, this problem will go away.

+5
source

You can upgrade to the latest version of virtualenv using:

 sudo pip install --upgrade https://github.com/pypa/virtualenv/archive/master.zip virtualenv --version # Returns 15.2.0.dev0 when I ran it 

Then the following command is executed:

 mkvirtualenv scriptcutter --python=/usr/bin/python3 

Apparently the development branch has been dropped, so the url with "develop" will no longer work. My answer was based on @pjotr_dolphin's comment with updated URL.

+1
source

Source: https://habr.com/ru/post/1232605/


All Articles