首页 > 解决方案 > “pip install mysqlclient”抛出错误:无法找到 vcvarsall.bat

问题描述

我正在尝试在 python 2.7 中安装 mysqlclient 模块。使用 pip 和 easy_install 会出现以下错误

> easy_install mysqlclient


Searching for mysqlclient
Reading https://pypi.python.org/simple/mysqlclient/
Best match: mysqlclient 1.3.12
Downloading https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2
adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz#sha256=2d9ec33d
e39f4d9c64ad7322ede0521d85829ce36a76f9dd3d6ab76a9c8648e5
Processing mysqlclient-1.3.12.tar.gz
Writing c:\users\home\appdata\local\temp\easy_install-9oa3ct\mysqlclient-1.3.12\
setup.cfg
Running mysqlclient-1.3.12\setup.py -q bdist_egg --dist-dir c:\users\home\appdat
a\local\temp\easy_install-9oa3ct\mysqlclient-1.3.12\egg-dist-tmp-kxvslf
error: Setup script exited with error: Unable to find vcvarsall.bat

pip 也有同样的错误。我了解某些模块包含 C 代码并且需要在安装之前进行编译,因此我安装了Microsoft Visual C++ Compiler for Python ,并将vcvarsall.bat的位置添加到新的系统环境变量VS90COMNTOOLS 中(其他答案表明这是 pip 搜索的位置vcvarsall.bat 的位置),但我仍然遇到同样的错误。

我需要在其他地方添加它的路径吗?pip 和 easy_install 在开始编译之前在哪里搜索文件?我该如何解决这个错误?

标签: pythonpip

解决方案


为我解决的是使用:

pip install --only-binary :all: mysqlclient

推荐阅读