Win7 64位编译Python扩展解决”error: Unable to find vcvarsall.bat”问题
2015-05-10 18:29
856 查看
经过测试,本文方法适用于安装了VCForPython27.msi但报同样错的情况。
以下为转载:
之前使用Win32系统,系统上安装有Visual Studio 2010以及相应的SDK,然后Python编译扩展命令
搜索了网上大多数解决方案,多是要你换用mingw32或者修改Python官方源代码的,使用mingw32时会出现形如
won’t compile on Windows 7 x64》找到这么一段文字,给我泼了一盆冷水:
I’d suggest you to switch to x86 Python, you gain no real advantage by using the x64 version. If you want to stick with x64, you can’t use MingW and you have to use MS SDK C++ compiler.
意思是无法使用MingW编译64位的Python扩展,如果一定那么做就必须使用MSVC微软的编译器,有人肯定会问为什么不使用64位的mingw64呢?原文作者也给出了说明,也可以参考《Compiling
64-bit extension modules on Windows》这篇文章:
** Do not use MinGW-w64. As you will notice, the MinGW import library for Python (e.g. libpython27.a) is omitted from the AMD64 version of Python. This is deliberate. Do not try to make one using dlltool. There is no official MinGW-w64 release
yet, it is still in “beta” and considered unstable, although you can get a 64-bit build from e.g. TDM-GCC. There have also been issues with the mingw runtime conflicting with the MSVC runtime; this can happen from places you don’t expect, such as inside runtime
libraries for g++ or gfortran. To stay on the safe side, avoid MinGW-w64 for now.
意思是mingw64还不稳定,存在一些问题,那刚才的问题又回到了起先,还有一个办法是改官方的安装脚本源代码,我觉得这样不太好,于是摸索了一番,正好又在stackoverflow上找到这么一篇文章《Building
64-bit C Python extensions on Windows》,然后问题被成功解决了!
下面我分享下可行的编译操作步骤:
1.打开64位Visual Studio 2010命令行编译模式,你可以依次从开始菜单 – Microsoft Visual Studio 2010 – Visual Studio Tools – Visual Studio x64 Win64 命令提示(2010),如下图所示:
2.使用下面的命令设置环境:
2.切换到所要编译的扩展setup.py所在路径运行下面的命令进行编译:
一会儿后如果相关依赖没有错误,并且源代码正确的话应该可以成功编译!编译完成后你可以从
如果编译出现问题,比如链接失败,你可以检查下环境设置是否有问题,比如系统Path变量是否包含
注:上述方案在Windows 7 x64、Visual Studio 2010以及Python 27 x64测试通过。
以下为转载:
之前使用Win32系统,系统上安装有Visual Studio 2010以及相应的SDK,然后Python编译扩展命令
python setup.py install但命令总是失败,出现
error: Unable to find vcvarsall.bat,比如编译py-bcrypt扩展:
running install running bdist_egg running egg_info writing py_bcrypt.egg-info\PKG-INFO writing top-level names to py_bcrypt.egg-info\top_level.txt writing dependency_links to py_bcrypt.egg-info\dependency_links.txt reading manifest file 'py_bcrypt.egg-info\SOURCES.txt' writing manifest file 'py_bcrypt.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py running build_ext building 'bcrypt._bcrypt' extension error: Unable to find vcvarsall.bat |
undefined reference to `_imp__Py...' build\temp.win-amd64-2.7无法链接到Python库的问题,本来想以这个为突破口寻求解决办法,结果在stackoverflow上《Cython
won’t compile on Windows 7 x64》找到这么一段文字,给我泼了一盆冷水:
I’d suggest you to switch to x86 Python, you gain no real advantage by using the x64 version. If you want to stick with x64, you can’t use MingW and you have to use MS SDK C++ compiler.
意思是无法使用MingW编译64位的Python扩展,如果一定那么做就必须使用MSVC微软的编译器,有人肯定会问为什么不使用64位的mingw64呢?原文作者也给出了说明,也可以参考《Compiling
64-bit extension modules on Windows》这篇文章:
** Do not use MinGW-w64. As you will notice, the MinGW import library for Python (e.g. libpython27.a) is omitted from the AMD64 version of Python. This is deliberate. Do not try to make one using dlltool. There is no official MinGW-w64 release
yet, it is still in “beta” and considered unstable, although you can get a 64-bit build from e.g. TDM-GCC. There have also been issues with the mingw runtime conflicting with the MSVC runtime; this can happen from places you don’t expect, such as inside runtime
libraries for g++ or gfortran. To stay on the safe side, avoid MinGW-w64 for now.
意思是mingw64还不稳定,存在一些问题,那刚才的问题又回到了起先,还有一个办法是改官方的安装脚本源代码,我觉得这样不太好,于是摸索了一番,正好又在stackoverflow上找到这么一篇文章《Building
64-bit C Python extensions on Windows》,然后问题被成功解决了!
下面我分享下可行的编译操作步骤:
1.打开64位Visual Studio 2010命令行编译模式,你可以依次从开始菜单 – Microsoft Visual Studio 2010 – Visual Studio Tools – Visual Studio x64 Win64 命令提示(2010),如下图所示:
2.使用下面的命令设置环境:
set DISTUTILS_USE_SDK=1 set MSSdk=1 |
python setup.py install |
build\lib.win-amd64-2.7\找到代码包,并且也已经安装进Python环境中去了。
如果编译出现问题,比如链接失败,你可以检查下环境设置是否有问题,比如系统Path变量是否包含
C:\Python27\libs假设Python装在C盘。
注:上述方案在Windows 7 x64、Visual Studio 2010以及Python 27 x64测试通过。
相关文章推荐
- python扩展问题”unable to find vcvarsall.bat“的解决
- Python扩展问题”unable to find vcvarsall.bat“的解决
- Visual Studio 2010编译Python扩展程序报error: Unable to find vcvarsall.bat
- Win7 64位编译Python扩展解决”error: Unable to find vcvarsa
- windows下Python扩展问题error: Unable to find vcvarsall.bat
- windows下安装python的C扩展编译环境(解决“Unable to find vcvarsall.bat”)
- 关于python下构建c模块出现error: Unable to find vcvarsall.bat问题的解决方法
- windows下安装python的C扩展编译环境(解决“Unable to find vcvarsall.bat”)
- Unable to find vcvarsall.bat Python扩展编译失败解决办法
- Python3 pip 解决问题: error: Unable to find vcvarsall.bat
- 64位win7中使用vs2013为python3.4安装pycrypto-2.6.1插件报Unable to find vcvarsall.bat异常解决方式
- windows下Python扩展问题error: Unable to find vcvarsall.bat
- windows下安装python的C扩展编译环境(解决Unable to find vcvarsall.bat)
- Windows系统 安装Python扩展包时出现“Misrosoft Visual C++ 9.0 is required / Unable to find vcvarsall.bat”的解决办法
- 解决Cython在Window下Python2.7中:Unable to find vcvarsall.bat的问题
- 对于解决python安装第三方包时候,报错 error: Unable to find vcvarsall.bat的终极秘诀
- Windows下安装Python扩展模块提示“Unable to find vcvarsall.bat”的问题
- Windows下Python快速解决error: Unable to find vcvarsall.bat
- 解决使用python3.5来获取PCL库出现 unable to find vcvarsall.bat的问题
- pip install scrapy报错:error: Unable to find vcvarsall.bat解决方法(python scrapy安装windows下)