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


当前回答

我在安装mayavi时遇到了这个问题。

我还犯了一个常见错误:在pip安装库时需要Microsoft Visual c++ 14.0。

在浏览了许多网页和这个问题的解决方案后,没有一个可行,我想出了这些步骤(大部分取自以前的解决方案)可以让这个问题起作用。

Go to Build Tools for Visual Studio 2017 and install Build Tools for Visual Studio 2017. Which is under All downloads (scroll down) → Tools for Visual Studio 2017 If you have already installed this, skip to 2. Select the C++ components you require (I didn't know which I required, so I installed many of them). If you have already installed Build Tools for Visual Studio 2017 then open the application Visual Studio Installer then go to Visual Studio Build Tools 2017 → Modify → Individual Components and selected the required components. From other answers, important components appear to be: C++/CLI support, VC++ 2017 version <...> latest, Visual C++ 2017 Redistributable Update, Visual C++ tools for CMake, Windows 10 SDK <...> for Desktop C++, Visual C++ Build Tools core features, Visual Studio C++ core features. Install/Modify these components for Visual Studio Build Tools 2017. This is the important step. Open the application Visual Studio Installer then go to Visual Studio Build Tools → Launch. Which will open a CMD window at the correct location for Microsoft Visual Studio\YYYY\BuildTools. Now enter python -m pip install --upgrade setuptools within this CMD window. Finally, in this same CMD window, pip install your Python library: pip install -U <library>.

其他回答

如果你已经安装了Visual Studio Build Tools(如其他评论中所述),并升级了setuptools,但仍然无法工作:

确保在x86或x64本机工具命令提示符下运行pip。

它可以在Windows开始菜单的VS文件夹下找到。默认的命令行提示符可能不会为Pip提供VS构建工具的路径,就像在我的情况下一样。

对于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

我有完全相同的问题,并通过安装mysql-connector-python解决了它:

pip install mysql-connector-python

我使用的是Python 3.7和Windows 10,安装Microsoft Build Tools for Visual Studio 2017(如这里所述)并没有解决我的问题,这与您的问题相同。

我已经有了vc++的v14+版本,但由于Anaconda遇到了问题。最终,下面的文件代替了使用pip、pipwin或wheel文件。

conda install <package_name_here>

这对我来说很管用: PIP install——only-binary:所有:mysqlclient