<div dir="ltr">Creating a virtualenv for python 3.4 from python 2.7 fails on Windows, complaining of an import missing: <div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font size="1">C:\test&gt; \Python27\</font></div>
<div><font size="1">Scripts\virtualenv.exe --clear -p \Python34\python.exe ..\pyvenv\pubsub_py34</font></div><div><font size="1">Running virtualenv with interpreter \Python34\python.exe</font></div><div><span style="font-size:x-small">Deleting tree ..\pyvenv\pubsub_py34\Lib</span><br>
</div><div><font size="1">Not deleting ..\pyvenv\pubsub_py34\Scripts</font></div><div><font size="1">Using base prefix &#39;C:\\Python34&#39;</font></div><div><font size="1">New python executable in ..\pyvenv\pubsub_py34\Scripts\python.exe</font></div>
<div><font size="1">Failed to import the site module</font></div><div><font size="1">Traceback (most recent call last):</font></div><div><font size="1">  File &quot;C:\Users\Oliver Schoenborn\Dropbox\Programming\pyvenv\pubsub_py34\lib\si</font><span style="font-size:x-small">te.py&quot;, line 67, in &lt;module&gt;</span></div>
<div><font size="1">    import os</font></div><div><font size="1">  File &quot;C:\Users\Oliver Schoenborn\Dropbox\Programming\pyvenv\pubsub_py34\lib\os</font><span style="font-size:x-small">.py&quot;, line 634, in &lt;module&gt;</span></div>
<div><font size="1">    from _collections_abc import MutableMapping</font></div><div><font size="1">ImportError: No module named &#39;_collections_abc&#39;</font></div><div><font size="1">ERROR: The executable ..\pyvenv\pubsub_py34\Scripts\python.exe is not functionin</font><span style="font-size:x-small">g</span></div>
<div><font size="1">ERROR: It thinks sys.prefix is &#39;c:\\users\\oliver schoenborn\\dropbox\\programmi</font><span style="font-size:x-small">ng\\pypubsub&#39; (should be &#39;c:\\users\\oliver schoenborn\\dropbox\\programming\\py</span><span style="font-size:x-small">venv\\pubsub_py34&#39;)</span></div>
<div><font size="1">ERROR: virtualenv is not compatible with this system or executable</font></div><div><font size="1">Note: some Windows users have reported this error when they installed Python for</font><span style="font-size:x-small"> &quot;Only this user&quot; or have multiple versions of Python installed. Copying the app</span><span style="font-size:x-small">ropriate PythonXX.dll to the virtualenv Scripts/ directory may fix this problem.</span></div>
</blockquote><div><br></div><div>The solution is to edit the file C:\Python27\Lib\site-packages\virtualenv.py: </div><div><ul><li>line 133 has &quot;if minver == 3:&quot;: change this to minver &gt;= 3 so it works for python 3.4<br>
</li><li>line 288, just before the &quot;if is_pypy:&quot; add the following code, which is specific to supporting 3.4: </li></ul><div><div>    if minver &gt;= 4:</div><div>        REQUIRED_MODULES.extend([</div><div>            #&#39;operator&#39;,</div>
<div>            &#39;_collections_abc&#39;,</div><div>            ])</div><div><br></div><div>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 &#39;operator&#39; module, or weakref, etc; which one depends on the traceback).         </div>
<span class=""><font color="#888888"><br></font></span></div><span class=""><font color="#888888">Oliver</font></span></div><div><span class=""><font color="#888888"><br></font></span></div></div>