I am trying to build the example that comes with the source distribution of python under PC\\example_nt
I copied example.c and setup.py to a directory C:\\mymod
When I run C:\\Python27\\python.exe setup.py install
I get the error....
error: Unable to find vcvarsall.bat
I did some digging around in distutils and saw that it was going after version 9 of microsoft visual studio but I only have version 8. Apparently it tries to get version 9 because of what the python under C:\\Python27 was compiled with.
I modified setup.py and put the following at the very top.
from distutils import msvc9compiler
msvc9compiler.VERSION = 8.0
After doing this I was able to compile and got the following....
C:\mymod>C:\Python27\python.exe setup.py install
running install
running build
running build_ext
building 'example' extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Program Files\Microsoft Visual Studio 8\VC\BIN\cl.exe /c /nologo /Ox /MD /W3
/GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tcexample.c /Fobuild\temp.
win32-2.7\Release\example.obj
example.c
creating build\lib.win32-2.7
C:\Program Files\Microsoft Visual Studio 8\VC\BIN\link.exe /DLL /nologo /INCREME
NTAL:NO /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild /EXPORT:initexamp
le build\temp.win32-2.7\Release\example.obj /OUT:build\lib.win32-2.7\example.pyd
/IMPLIB:build\temp.win32-2.7\Release\example.lib /MANIFESTFILE:build\temp.win32
-2.7\Release\example.pyd.manifest
Creating library build\temp.win32-2.7\Release\example.lib and object build\te
mp.win32-2.7\Release\example.exp
C:\Program Files\Microsoft Visual Studio 8\VC\BIN\mt.exe -nologo -manifest build
\temp.win32-2.7\Release\example.pyd.manifest -outputresource:build\lib.win32-2.7
\example.pyd;2
running install_lib
copying build\lib.win32-2.7\example.pyd -> C:\Python27\Lib\site-packages
running install_egg_info
Removing C:\Python27\Lib\site-packages\example-1.0-py2.7.egg-info
Writing C:\Python27\Lib\site-packages\example-1.0-py2.7.egg-info
Now when I run C:\\Python27\\python.exe and try to import example
I get the following...
ImportError: DLL load failed: The specified module could not be found.
Did I do something wrong? Is VS8 unsupported for creating Python 2.7 modules? What should I do?
Ultimately I need to build bindings for some Windows C library so that I can use Python to extend some proprietary program instead of C. I have to use VS8 for creating the C extension. So where does that leave me.
Advice please.
Thanks, ~Eric
Generally speaking you have to build the python modules using the same version of VS as python was built with. You have several options:
I'd recommend option 1 if it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.