python-future: virtualenv + python-future = broken virtualenv

Simplest reproduction:

$ virtualenv venv
$ ./venv/bin/pip install future virtualenv
Collecting future
  Using cached future-0.14.3.tar.gz
Collecting virtualenv
  Using cached virtualenv-12.1.1-py2.py3-none-any.whl
Installing collected packages: future, virtualenv
  Running setup.py install for future
Successfully installed future-0.14.3 virtualenv-12.1.1
$ ./venv/bin/virtualenv -ppython3.4 venv34
Running virtualenv with interpreter /usr/bin/python3.4
Traceback (most recent call last):
  File "/home/anthony/venv/local/lib/python2.7/site-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 "/home/anthony/venv/lib/python2.7/site-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.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 18 (3 by maintainers)

Most upvoted comments

For Ubuntu 14.04, this combination worked for me:

$ wget https://bootstrap.pypa.io/get-pip.py -O - | sudo python3.4
  • Replace the old virtualenv (python 2.7 to python 3.4) :
$ sudo pip3.4 install virtualenv
  • Just to check:
$ head -n 1 /usr/local/bin/virtualenv
#!/usr/bin/python3
  • Now, the following commands will run:
$ virtualenv venv34
Using base prefix '/usr'
New python executable in venv34/bin/python3
Also creating executable in venv34/bin/python
Installing setuptools, pip, wheel...done.

$ ./venv34/bin/pip install virtualenv
Collecting virtualenv
  Using cached virtualenv-13.1.2-py2.py3-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv-13.1.2

$ ./venv34/bin/virtualenv -p python venv
Running virtualenv with interpreter /usr/bin/python
New python executable in venv/bin/python
Installing setuptools, pip, wheel...done.

$ /usr/bin/python --version
Python 2.7.6

$ ./venv/bin/pip install future virtualenv
Collecting future
Collecting virtualenv
  Using cached virtualenv-13.1.2-py2.py3-none-any.whl
Installing collected packages: future, virtualenv
Successfully installed future-0.15.2 virtualenv-13.1.2

$ ./venv34/bin/pip install future
Collecting future
Installing collected packages: future
Successfully installed future-0.15.2
  • To avoid compilation errors from Python extensions written in C or C++ (ref):
$ sudo apt-get update
$ sudo apt-get install -y build-essential
$ sudo apt-get install -y python3.4-dev
$ sudo apt-get install -y python3-software-properties

Now, tox runs beautifully 😃