我已经安装了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正确安装模块。


当前回答

首先,你需要从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包

其他回答

要解决以下任何错误:

misaka的车轮建造失败 建造misaka失败 需要Microsoft Visual c++ 14.0 无法找到vcvarsall.bat

解决方案是:

Go to Build Tools for Visual Studio 2017 Select free download under Visual Studio Community 2017. This will download the installer. Run the installer. Select what you need under workload tab: a. Under Windows, there are three choices. Only check Desktop development with C++. b. Under Web & Cloud, there are seven choices. Only check Python development (I believe this is optional, but I have done it). In cmd, type pip3 install misaka. Note if you already installed Visual Studio then when you run the installer, you can modify yours (click modify button under Visual Studio Community 2017) and do steps 3 and 4. Final note: If you don't want to install all modules, having the three below (or a newer version of the VC++ 2017) would be sufficient. (You can also install the Visual Studio Build Tools with only these options, so you don’t need to install Visual Studio Community Edition itself) => This minimal install is already a 4.5 GB, so saving off anything is helpful

我也有同样的问题。下载Visual Studio 2017的构建工具对我有用。

使用此链接下载并安装Visual c++ 2015 Build Tools。它将自动下载visualcppbuildtools_full.exe并安装Visual c++ 14.0,而无需实际安装Visual Studio。

安装完成后,重试pip install,您将不会再次得到错误。

我已经在以下平台和版本上进行了测试:

Python 3.6 on Windows 7 64-bit
Python 3.8 on Windows 10 64-bit

二进制安装它的简单方法!

使用pip的二进制选项。例如,对于mysqlclient:

pip install --only-binary :all: mysqlclient

许多包不会为每个单独的版本创建一个构建,这迫使您的pip从源代码构建。如果您乐于使用最新的预编译二进制版本,请使用——only-binary:all:允许pip使用较旧的二进制版本。

这里和其他地方的解决方案都不适合我。我的64位Windows 10操作系统上安装了一个不兼容的32位版本的mysqlclient,因为我使用的是32位版本的Python。

我不得不卸载我目前的Python 3.7 32位,并重新安装Python 3.7 64位,现在一切都很好。