Python 3.6 and Visual Studio 2017 6


As a new version of Visual Studio comes out, there are often fixes to put in your build chain tools so packages with external  C/C++ compilation requirements still work. For Python 3.6 and Visual Studio 2017 to work together, a good reference start point is the Windows compilers compatibility list on python.org.

Let’s try to compile scrapy which has a lot of dependencies including the twisted package.

Let’s assume you have installed “Visual Studio 2017 Community” on your PC with the C++ support. Trying to run the well-known

will end-up with a compile error, such as the following:

When working with Python 3.6 you may find however many stackoverflow articles stating that you must install Visual Studio 2015 back. Save yourself time and space by not doing it.

As mentioned as a requirement in the previously mentioned article, one requirement is to have a version of the setuptools library which is higher than 34.0. Unfortunately, Python 3.6 comes with 28.0 and the simple

won’t work as it tells you you have already what’s needed. Use instead:

If everything goes well, you’ll have:

This will allow Python to access your Visual Studio 2017 installation and no longer have two versions or more  installed in parallel.

The last trick is to use the proper environment to run command-line installations. With Visual Studio 2017 come multiple command prompts setups:

Do not choose ‘Developer’ although it may sound appealing. You’ll get caught with LNK2010  linking errors because of INCLUDE issues, in the same way that a regular cmd would output the  following error:

For proper compilation, choose the native architecture. In my case, I Choose ‘x64 Native Tools’ and finally got the following successful result:

 


Leave a comment

Your email address will not be published. Required fields are marked *

6 thoughts on “Python 3.6 and Visual Studio 2017

  • Ar one

    Thank you very much! Like a lot!!
    I couldn’t be bothered to download a humongous 4GB redundant older version c++ build tools, when I already have the latest ones.
    I tried searching for steps to make python choose the latest vs version for the build, but there were no relevant solutions. This one worked as a charm 🙂

  • Patrick

    Thank you very much for your solution. Worked perfectly! I did have to run the Command Prompt as administrator because I got an access denied error for read/write operations. Right mouse click Command Prompt as select: Run as administrator.