我已经安装了Python 3.5,并且正在运行

pip install mysql-python

它给出了如下错误

错误:Microsoft Visual c++ 14.0是必需的(无法找到vcvarsall.bat)

我已经添加了以下行到我的路径

C:\Program Files\Python 3.5\Scripts\;
C:\Program Files\Python 3.5\;

C:\Windows\System32;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC

我的电脑上安装了64位的Windows 7。

什么解决方案可以减少这个错误,并通过pip正确安装模块。


当前回答

执行vcvars64.bat

在无休止地搜索类似的问题,但没有一个解决方案。 -添加无尽的文件夹到我的路径和删除他们。卸载和重新安装visual studio社区和构建工具。 一步一步地尝试调试,我终于找到了一个适合我的解决方案。

(如果有人有类似情况,请提供背景说明) 我最近重置了我的主计算机,在重新安装了最新版本的python (Python3.9)库之后,我曾经安装过,没有任何麻烦(主要示例pip install opencv-python)

cl
    is not a full path and was not found in the PATH.

将cl添加到路径from之后 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64

和几个不同的Windows套件,一次得到以下。

The C compiler

"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe"

is not able to compile a simple test program.

各种链接错误或“运行构建命令:jom /nologo cmTC_7c75e\fast &&系统无法找到指定的文件”

从常规命令行和管理命令行升级setuptools和wheel,与手动下载wheel或尝试使用——only-binary:all安装相比,没有任何作用:

最后,为我工作的最终结果是运行正确的vcvars.bat为我的python安装,即运行 “C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat”一次(不是vcvarsall或vcvars32)(因为我安装的python是64位),然后运行常规命令pip install opencv-python工作。

其他回答

看看这个包是否有一个正式的分叉,包括必要的二进制轮。

我需要包python-Levenshtein,有这个错误,并找到包python-Levenshtein-wheels。

再加上乔杜里的回答:

在我的情况下,我得到了另一个关于lxml的错误如下:

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-3.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

我必须安装lxml - 4.2.3 - cp37 - cp37m - win_amd64。与Sushant Chaudhary的回答一样,成功完成Scrapy的安装。

下载lxml 4.2.3——cp37 cp37m——win_amd64。whl来自Lxml 把它放在Python安装的文件夹里 使用PIP Install <file-name>安装它

现在您可以运行pip install scrapy。

对于Python 3.7.4,以下一组命令可以工作: 在执行这些命令之前,您需要确认Visual Studio中已经安装了Desktop with c++ and Python。

cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
vcvarsall.bat x86_amd64
cd \
set CL=-FI"%VCINSTALLDIR%\tools\msvc\14.16.27023\include\stdint.h"
    
pip install pycrypto

在Stack Overflow上阅读了很多答案后,没有一个可以工作,我最终设法按照这个问题中的步骤解决它。我将把步骤留在这里,以防页面消失:

请尝试安装Visual Studio 2017的构建工具,选择工作负载“Visual c++构建工具”,并检查选项“c++ /CLI支持”和“vc++ 2015.3 v14.00 (v140)桌面工具集”,如下所示。

首先,你需要从https://visualstudio.microsoft.com/downloads#other下载visualstudio构建工具 重命名文件vs_buildtools.exe(不是必需的,但您必须修改下面的脚本)

start-process -wait -filepath vs_buildtools.exe -ArgumentList '--quiet --wait --norestart --nocache --installPath C:\BuildTools `
  --add Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64 `
  --add Microsoft.VisualStudio.Component.Windows10SDK.19041 `
  --add Microsoft.VisualStudio.Component.Windows10SDK `
  --add Microsoft.VisualStudio.Component.VC.CoreIde `
  --add Microsoft.VisualStudio.Component.VC.CMake.Project `
  --add Microsoft.VisualStudio.Component.VC.14.29.16.11.CLI.Support `
  --add Microsoft.VisualStudio.ComponentGroup.UWP.VC.v142'

我在这里为windows docker用户创建了一个单独的问题和答案,Microsoft Visual c++ 14.0是必需的,在windows docker上安装pip包