我尝试安装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
当前回答
我没有看到任何使用vswhere的答案,我认为这是自Visual Studio 15.2以来正确的方法。
下面是我运行vsvars64.bat的方法(我想这与vsvarsall类似)
def init_vsvars():
cprint("")
cprint_header("Initializing vs vars")
vswhere_path = r"%ProgramFiles(x86)%/Microsoft Visual Studio/Installer/vswhere.exe"
vswhere_path = path.expandvars(vswhere_path)
if not path.exists(vswhere_path):
raise EnvironmentError("vswhere.exe not found at: %s", vswhere_path)
vs_path = common.run_process(".", vswhere_path,
["-latest", "-property", "installationPath"])
vs_path = vs_path.rstrip()
vsvars_path = os.path.join(vs_path, "VC/Auxiliary/Build/vcvars64.bat")
# common.run_process(".", vsvars_path, [])
os.system('"%s"' % vsvars_path)
run_process做了很多事情,但基本上归结为:
output = ""
process = subprocess.Popen(
commandline,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
for stdout_line in iter(process.stdout.readline, ""):
cprint(stdout_line)
output += stdout_line
process.stdout.close()
return_code = process.wait()
return output
其他回答
使用此链接下载并安装Visual C++2015生成工具。它将自动下载visualcppbuildtools_full.exe并安装Visual C++14.0,而无需实际安装Visual Studio。安装完成后,重试pip安装,您将不会再次出现错误。
我已经在以下平台和版本上测试了它:
Python 3.6 on Windows 7 64-bit
Python 3.7 on Windows Server 2016 (64-bit system)
Python 3.8 on Windows 10 64-bit
我遵守了指示http://springflex.blogspot.ru/2014/02/how-to-fix-valueerror-when-trying-to.html.但什么都没发生。然后我安装了2010 Visual Studio Express(http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express)遵循建议http://blog.python.org/2012/05/recent-windows-changes-in-python-33.html它帮助了我
也许有人会感兴趣,下面的内容适用于py2exe包。(我有windows 7 64位和可移植python 2.7,Visual Studio 2005 Express以及windows 7和.NET Framework 4的windows SDK)
set VS90COMNTOOLS=%VS80COMNTOOLS%
那么:
python.exe setup.py install
我找到了解决方案。我也遇到了同样的问题和错误,安装“amara”。我安装了mingw32,但需要配置distutils。
我已经安装了Python 2.6。我将mingw32安装到C:\programs\mingw\将mingw32的bin目录添加到环境变量:append c:\programs\MinGW\bin;到PATH将位于C:\Python26\Lib\distutils\distutils.cfg的distutils.cfg文件编辑为:[生成]编译器=mingw32现在运行easy_install.exe amara。
确保通过打开新的cmd.exe来设置环境。
我也遇到了同样的问题,现在已经解决了。
“谷歌”告诉我,我需要安装“Microsoft Visual C++编译器Python 2.7版”。我不仅安装了该工具,还安装了Visual C++2008 Reditributable,但无济于事。然后我尝试安装Visual C++2008速成版。问题已经解决了!
只需尝试安装Visual C++2008速成版!