Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>If you want to compile with Visual Studio C++ instead of mingw...</h2> <ol> <li><p>Run <code>python.exe</code> to display which version of VC++ it was compiled with (example shown below).</p> <blockquote> <p>It is <strong>important</strong> to use the corresponding version of the Visual C++ compiler that Python was compiled with since <a href="http://svn.python.org/projects/python/branches/release27-maint/Lib/distutils/msvc9compiler.py" rel="nofollow noreferrer">distilutils</a>'s <code>get_build_version</code> prevents mixing versions (<a href="https://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat#comment-23311731">per Piotr's warning</a>).</p> </blockquote> <ul> <li>Yellow (top) is Python 2.7, compiled with MSC v.1500 (Visual Studio C++ 2008)</li> <li>Red (bottom) is Python 3.4.1, compiled with MSC v.1600 (Visual Studio C++ 2010)</li> </ul> <p><img src="https://i.stack.imgur.com/jzygw.png" alt="Example from the command line showing Python 2.7 compiled with MSC v.1500 and Python 3.4.1 compiled with MSC v.1600"></p></li> <li><p>Use the table below<sup><a href="https://stackoverflow.com/a/2676904/809572">[1]</a></sup> to match the internal VC++ version with the corresponding Visual Studio release:</p> <pre><code>MSC v.1000 -&gt; Visual C++ 4.x MSC v.1100 -&gt; Visual C++ 5 MSC v.1200 -&gt; Visual C++ 6 MSC v.1300 -&gt; Visual C++ .NET MSC v.1310 -&gt; Visual C++ .NET 2003 MSC v.1400 -&gt; Visual C++ 2005 (8.0) MSC v.1500 -&gt; Visual C++ 2008 (9.0) MSC v.1600 -&gt; Visual C++ 2010 (10.0) MSC v.1700 -&gt; Visual C++ 2012 (11.0) MSC v.1800 -&gt; Visual C++ 2013 (12.0) MSC v.1900 -&gt; Visual C++ 2015 (14.0) MSC v.1910 -&gt; Visual C++ 2017 (15.0) </code></pre></li> <li><p>Download and install the corresponding version of Visual Studio C++ from the previous step.<br> Additional notes for specific versions of VC++ are listed below. </p> <h3>Notes for Visual Studio C++ 2008</h3> <p>For <em>only</em> the 32-bit compilers, download <a href="http://download.microsoft.com/download/A/5/4/A54BADB6-9C3F-478D-8657-93B3FC9FE62D/vcsetup.exe" rel="nofollow noreferrer">Visual Studio C++ 2008 Express Edition</a>.</p> <p>For the 64-bit compilers<sup><a href="http://blog.victorjabur.com/2011/06/05/compiling-python-2-7-modules-on-windows-32-and-64-using-msvc-2008-express/" rel="nofollow noreferrer">[2]</a></sup><sup><a href="http://smaudet.wordpress.com/2014/01/26/building-pyaudio-on-windows-7-x64-using-the-free-msvc-toolchains/" rel="nofollow noreferrer">[3]</a></sup>, download <a href="http://www.microsoft.com/en-us/download/details.aspx?id=3138" rel="nofollow noreferrer">Windows SDK for Windows 7 and .NET Framework 3.5 SP1</a>. </p> <blockquote> <ul> <li>Uncheck everything except <code>Developer Tools &gt;&gt; Visual C++ Compilers</code> to save time and disk space from installing SDK tools you otherwise don't need. </li> </ul> </blockquote> <h3>Notes for Visual Studio C++ 2010</h3> <p>According to Microsoft, if you installed Visual Studio 2010 SP1, it may have removed the compilers and libraries for VC++.<br> If that is the case, download <a href="https://www.microsoft.com/en-us/download/details.aspx?id=4422" rel="nofollow noreferrer">Visual C++ 2010 SP1 Compiler Update</a>.</p> <h3>Notes for Visual Studio C++ 2015</h3> <p>If you don't need the Visual Studio IDE, download <a href="http://landinghub.visualstudio.com/visual-cpp-build-tools" rel="nofollow noreferrer">Visual Studio C++ 2015 Build Tools</a>.</p> <h3>Notes for Visual Studio C++ 2017</h3> <p>If you don't need the Visual Studio IDE, download <a href="https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017" rel="nofollow noreferrer">Build Tools for Visual Studio 2017</a>.</p> <p><strong>Suggestion</strong>: If you have both a 32- and 64-bit Python installation, you may also want to use <a href="http://www.virtualenv.org/en/latest/virtualenv.html" rel="nofollow noreferrer">virtualenv</a> to create separate Python environments so you can use one or the other at a time without messing with your path to choose which Python version to use.</p></li> </ol> <blockquote> <p>According to <a href="https://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat#comment35207766_18045219">@srodriguex</a>, you may be able to skip manually loading the batch file (Steps 4-6) by instead copying a few batch files to where Python is searching by following <a href="https://stackoverflow.com/questions/13596407/errors-while-building-installing-c-module-for-python-2-7/21898585#21898585">this answer</a>. If that doesn't work, here are the following steps that originally worked for me.</p> </blockquote> <ol start="4"> <li><p>Open up a <code>cmd.exe</code></p></li> <li><p><em>Before</em> you try installing something which requires C extensions, run the following batch file to load the VC++ compiler's environment into the session (i.e. environment variables, the path to the compiler, etc). </p> <p><strong>Execute:</strong> </p> <ul> <li><p>32-bit Compilers:</p> <p><em>Note</em>: 32-bit Windows installs will only have <code>C:\Program Files\</code> as expected</p> <blockquote> <p><code>"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"</code></p> </blockquote></li> <li><p>64-bit Compilers:</p> <blockquote> <p><code>"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars64.bat"</code></p> </blockquote> <p><em>Note</em>: Yes, the native 64-bit compilers are in <code>Program Files (x86)</code>. Don't ask me why.<br> Additionally, if you are wondering what the difference between <code>vcvars64.bat</code> and <code>vcvarsx86_amd64.bat</code> or more importantly the difference between <code>amd64</code> and <code>x86_amd64</code>, the former are for the native 64-bit compiler tools and the latter are the 64-bit cross compilers that can run on a 32-bit Windows installation.</p></li> </ul> <p><strong>Update:</strong><br> If for some reason you are getting <code>error: ... was unexpected at this time.</code> where the <code>...</code> is some series of characters, then you need to check that you path variable does not have any extraneous characters like extra quotations or stray characters. The batch file is not going to be able to update your session path if it can't make sense of it in the first place.</p></li> <li><p>If that went well, you should get one of the following messages depending on which version of VC++ and which command you ran: </p> <p>For the 32-bit compiler tools:<br> <code>Setting environment for using Microsoft Visual Studio 20xx x86 tools.</code> </p> <p>For the 64-bit compiler tools:<br> <code>Setting environment for using Microsoft Visual Studio 20xx x64 tools.</code></p></li> <li><p><em>Now</em>, run the setup via <code>python setup.py install</code> or <code>pip install pkg-name</code></p></li> <li><p>Hope and cross your fingers that the planets are aligned correctly for VC++ to cooperate.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload