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


当前回答

如果Visual Studio不是你的东西,而你正在使用VS Code,那么这个链接将指导你通过安装程序让c++在你的Windows上运行。

您只需要完成先决条件部分。 https://code.visualstudio.com/docs/cpp/config-msvc/#_prerequisites

这与其他答案相似,但这个链接可能比这里的一些回答更陈旧。

PS:别忘了运行pip install——upgrade setuptools

其他回答

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

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

pip install --only-binary :all: mysqlclient

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

只要去https://www.lfd.uci.edu/~gohlke/pythonlibs/找到适合你的包(whl文件)。下载它。在cmd中进入下载文件夹,或者在文件夹的地址栏上输入'cmd'。执行如下命令:

pip install mysqlclient-1.4.6-cp38-cp38-win32.whl

(请正确输入文件名。我只是举了一个例子)。无需安装6GB大小的build toll cpp,您的问题将得到解决。

我在安装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>.

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

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

我只是在使用最新的Python 3.6时遇到了同样的问题。Windows OS 10家庭版和64位操作系统。

解决方法:

通过控制面板卸载任何版本的Visual Studio 安装Visual Studio 2015并选择将安装的默认选项 Visual c++ 14.0 您可以使用PyCharm安装Scrapy:菜单项目→项目解释器→+(安装Scrapy) 通过导入检查REPL和PyCharm中的Scrapy。您应该不会看到任何错误。