更新时间:2023-11-16 23:23:16
更新:评论指出此处的说明可能很危险.考虑使用Visual C ++ 2008 Express版或专用的 Microsoft Visual适用于Python的C ++编译器(详细信息)和不,请使用以下原始答案.原始错误消息表示未安装所需的Visual C ++版本.
对于Windows安装:
在运行setup.py进行软件包安装时,Python 2.7搜索已安装的Visual Studio2008.您可以通过在调用setup.py
之前在VS90COMNTOOLS
环境变量中设置正确的路径来欺骗Python使用新的Visual Studio. /p>
根据安装的Visual Studio版本执行以下命令:
SET VS90COMNTOOLS=%VS100COMNTOOLS%
SET VS90COMNTOOLS=%VS110COMNTOOLS%
SET VS90COMNTOOLS=%VS120COMNTOOLS%
SET VS90COMNTOOLS=%VS140COMNTOOLS%
警告:如下所述,如果您尝试编译python模块,则此答案不太可能起作用.
有关详细信息,请参见在Windows上为Python 2.7构建lxml .
I tried to install the Python package dulwich:
pip install dulwich
But I get a cryptic error message:
error: Unable to find vcvarsall.bat
The same happens if I try installing the package manually:
> python setup.py install
running build_ext
building 'dulwich._objects' extension
error: Unable to find vcvarsall.bat
Update: Comments point out that the instructions here may be dangerous. Consider using the Visual C++ 2008 Express edition or the purpose-built Microsoft Visual C++ Compiler for Python (details) and NOT using the original answer below. Original error message means the required version of Visual C++ is not installed.
For Windows installations:
While running setup.py for package installations, Python 2.7 searches for an installed Visual Studio 2008. You can trick Python to use a newer Visual Studio by setting the correct path in VS90COMNTOOLS
environment variable before calling setup.py
.
Execute the following command based on the version of Visual Studio installed:
SET VS90COMNTOOLS=%VS100COMNTOOLS%
SET VS90COMNTOOLS=%VS110COMNTOOLS%
SET VS90COMNTOOLS=%VS120COMNTOOLS%
SET VS90COMNTOOLS=%VS140COMNTOOLS%
WARNING: As noted below, this answer is unlikely to work if you are trying to compile python modules.
See Building lxml for Python 2.7 on Windows for details.