我尝试安装Python包dulwich:
pip install dulwich
但我收到了一条神秘的错误消息:
error: Unable to find vcvarsall.bat
如果我尝试手动安装软件包,也会发生同样的情况:
> python setup.py install
running build_ext
building 'dulwich._objects' extension
error: Unable to find vcvarsall.bat
我尝试安装Python包dulwich:
pip install dulwich
但我收到了一条神秘的错误消息:
error: Unable to find vcvarsall.bat
如果我尝试手动安装软件包,也会发生同样的情况:
> python setup.py install
running build_ext
building 'dulwich._objects' extension
error: Unable to find vcvarsall.bat
当前回答
我想在Windows 10上使用Python 2.7运行pysph,但没有找到vcvarsall.bat(来自distutils)
我的解决方案如下:
安装Microsoft Visual C++for Python 2.7(如@Michael建议的那样)
在Windows 10上,它安装到(我的用户名是Andreas):
C:\Users\Andreas\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
将环境变量VS90COMNTOOLS设置为Visual C++for Python 2.7的安装路径(请参见上面的路径)。
如果仍然不起作用,则在模块中进行修改
C:/Python27/lib/distutils
文件msvc9compiler.py。在其中查找函数Find_vcvarsall并执行以下修改。
更换管路:
productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC")
with
productdir = os.path.join(toolsdir)
在我的案例中,这就是vcvarsall.bat所在的位置(请检查,vcvarsall.bat在您的安装中)。
其他回答
当我尝试在windows 10中安装panda时,也出现了同样的错误。在搜索了几个解决方案后,我最终使用了轮子。
首先,将pip升级到最新版本:
easy_install install -U pip
第二,安装车轮:
pip install wheel
第三,下载软件包的whl文件并安装:
pip install [xxx].whl
到目前为止,我认为wheel是在windows上安装Python包的最佳方式。
我有python 2.73和windows 7。对我有效的解决方案是:
将mingw32的bin目录添加到环境变量:用C:\programs\mingw\bin追加PATH;已创建distutils.cfg,位于C:\Python27\Lib\distutils\distutils.ccfg,包含:[生成]编译器=mingw32
要处理MinGW不再识别-mno cygwin标志的问题,请删除C:\Python27\Lib\distutils\cygwincompiler.py第322到326行中的标志,因此如下所示:
self.set_executables(compiler='gcc -O -Wall',
compiler_so='gcc -mdll -O -Wall',
compiler_cxx='g++ -O -Wall',
linker_exe='gcc',
linker_so='%s %s %s'
% (self.linker_dll, shared_option,
entry_point))
从安装Visual Studio 2015社区版https://www.visualstudio.com,然后
对于Python 3.4
设置VS100COMNTOOLS=%VS140COMNTOOLS%&&pip安装XX
我找到了一个更简单的方法。只需从网站下载二进制文件包:http://www.lfd.uci.edu/~gohlke/pythonlibs'例如:autopy3‑0.51.1‑cp36‑cp36m‑win32.whl(cp36表示Python 3.6)下载它并通过pip安装文件的位置
我尝试了以上所有的答案,但没有为我工作。我使用的是Windows 10,并安装了Visual Studio 2010在我的情况下,需要将vcvars64.bat添加到C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\bin\amd64
下面是vcvars64.bat:
CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
如果未安装,请安装Microsoft SDK 7.1,然后重新运行pip Install dulwich