python - “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 在开始编译之前在哪里搜索文件?我该如何解决这个错误?
解决方案
为我解决的是使用:
pip install --only-binary :all: mysqlclient
推荐阅读
- node.js - 节点 10.15.0:无法创建大矩阵
- pointers - LLVM 编译器基础结构中是否有办法将指针常量转换为不同类型的指针常量?
- jquery - Jquery 搜索常见问题解答 - 不区分大小写
- c - 为什么 pow(10,2) 的结果是 99 而不是 100?
- swift - Xcode 10.1 调试器 - 如何在 Xcode 的调试器中查看整个对象集合?
- leaflet - 从 50% 不透明度的 tilelayer WMS 生成图像
- artificial-intelligence - Fluid-synth 始终确保存在银行编号
- ruby-on-rails - AJAX Ruby on Rails | 部分不重新渲染
- scala - 从 Scala 中的抽象类创建匿名类 - 脱糖代码
- c# - 如何将现有类转换为带有事件的 DDD 聚合?