[TIP] virtualenv bug with python 3.4.0a4

oliver oliver.schoenborn at gmail.com
Mon Nov 25 18:31:27 PST 2013

Creating a virtualenv for python 3.4 from python 2.7 fails on Windows,
complaining of an import missing:

C:\test> \Python27\
Scripts\virtualenv.exe --clear -p \Python34\python.exe ..\pyvenv\pubsub_py34
Running virtualenv with interpreter \Python34\python.exe
Deleting tree ..\pyvenv\pubsub_py34\Lib
Not deleting ..\pyvenv\pubsub_py34\Scripts
Using base prefix 'C:\\Python34'
New python executable in ..\pyvenv\pubsub_py34\Scripts\python.exe
Failed to import the site module
Traceback (most recent call last):
  File "C:\Users\Oliver
Schoenborn\Dropbox\Programming\pyvenv\pubsub_py34\lib\site.py", line 67, in
    import os
  File "C:\Users\Oliver
Schoenborn\Dropbox\Programming\pyvenv\pubsub_py34\lib\os.py", line 634, in
    from _collections_abc import MutableMapping
ImportError: No module named '_collections_abc'
ERROR: The executable ..\pyvenv\pubsub_py34\Scripts\python.exe is not
ERROR: It thinks sys.prefix is 'c:\\users\\oliver
schoenborn\\dropbox\\programming\\pypubsub' (should be 'c:\\users\\oliver
ERROR: virtualenv is not compatible with this system or executable
Note: some Windows users have reported this error when they installed
Python for "Only this user" or have multiple versions of Python installed.
Copying the appropriate PythonXX.dll to the virtualenv Scripts/ directory
may fix this problem.

The solution is to edit the
file C:\Python27\Lib\site-packages\virtualenv.py:

   - line 133 has "if minver == 3:": change this to minver >= 3 so it works
   for python 3.4
   - line 288, just before the "if is_pypy:" add the following code, which
   is specific to supporting 3.4:

    if minver >= 4:

Be careful of indentation, you want that code to run only if major version
is 3. Also, which modules you add there seems to depend on the specific
release (3.4.0a4, for me, required the _collections_abc; other releases may
need instead the 'operator' module, or weakref, etc; which one depends on
the traceback).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20131125/175f5bc9/attachment.htm>

More information about the testing-in-python mailing list