Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install python modules with Visual Studio 2008 on Windows x64

I try installing python modules (this time flask-bcrypt or py-bcrypt) and I can't get it to work because compilation failed.

I learned that I needed Visual Studio 2008 (I do own 2010 Professional, but it seems thats not enough). So I downloaded the Express Edition and ran again. This time it failed with some ValueError on path which turned out to be an issue with Python being x64 but Visual Studio being 32 bit.

I then made a search and did not find a single opportunity to configure my Express Edition for x64. All tutorials assumed the Professional version.

It can't seriously be correct that I need to buy the Professional version to be able to compile this plugins without some hacking in the code, can it?

Is there any easy way to get this stuff up and running. I would be glad to see someone provide a generic solution like

  • Install python
  • Install xyz
  • Do this and that

So that I can finally just run the usual Unix commands like pip install abc to install a module. I got this up and running with virtualenv finally, but as soon as I need to compile I get stuck again.

like image 882
javex Avatar asked Dec 20 '22 20:12

javex


1 Answers

The command line VS 2008 compilers are included with "Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 Service Pack 1". During on the download and installation, make sure you select the x64 compiler.

Once you have the SDK installed, Python can build extensions without a copy of Visual Studio (Express or Professional) installed. It just takes a few commands to properly configure the environment.

I've extracted the following from my notes:

rem Configure the environment for 64-bit builds.
rem Use "vcvars32.bat" for a 32-bit build.
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat"

rem Convince setup.py to use the SDK tools.
set MSSdk=1
set DISTUTILS_USE_SDK=1

python setup.py install should now work. I don't know if anything special needs to be done to support pip.

like image 77
casevh Avatar answered May 13 '23 18:05

casevh