python - 在 Windows 中的 Python 3.6 中安装 mysqlclient

标签 python pip mysql-python python-wheel

我想在我的windows系统上安装MySqlclient。我目前正在使用 Python 3.6。在浏览了 Stackoverflow 上的各种帖子后,我找不到正确的方法。 这是我到目前为止所做的:

1) 使用 pip pip install mysqlclient 安装。错误:

Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools" http://landinghub.visualstudio.com/visual-cpp-build-tools

我的笔记本电脑上已经安装了 Microsoft Visual C++。有人说您需要 2015 版。

2) 使用 wheel 文件 pip install mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl 安装。错误:

Requirement mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl looks like a filename, but the file does not exist. mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.

2.1) 将 whl 文件更改为不同版本 pip install mysqlclient-1.3.13-cp36-cp36m-win32.whl。错误:

Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\Foxtrot\\Desktop\\finaltest\\mysqlclient-1.3.13-cp36-cp36m-win32.whl'

完成的其他事情:更新设置工具、更新轮子。

最佳答案

有同样的问题,在网上搜索等。这里是这个答案:

mysql-python install error: Cannot open include file 'config-win.h'

它有所有的说明。总之去这个网站:https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient :

在那个网站你会找到
mysqlclient‑1.3.13‑cp36‑cp36m‑win32.whl
mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl

为您的平台下载正确的文件。

然后将下载的 wheels 文件与 pip 一起使用,就完成了:

pip install c:\mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl

https://www.lfd.uci.edu/~gohlke/pythonlibs有很多编译库来解决自己从源代码构建它们的问题。他们甚至为 python 3.7 编译它们 :)

替代解决方案

您还可以下载 Visual C++ 构建工具,然后您应该能够使用 pip 安装每个(至少据我所知)版本的 mysqlclient。

要执行此操作,请访问此站 pip :https://www.scivision.co/python-windows-visual-c++-14-required/在那里您可以找到所需的构建工具版本,还可以找到下载安装程序的链接。请注意,尽管构建工具需要超过 4GB 的可用磁盘空间。

关于python - 在 Windows 中的 Python 3.6 中安装 mysqlclient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51146117/

相关文章:

Python三角求索,打印里面的算术运算

python - 如何确定 Python 是使用 UCS-2 还是 UCS-4 编译的?

python - 从 MySQL 数据库中选择数据并使用 Python 将其设为值

Python 对象作用域问题

python - 代码花费太多时间

apache - 没有名为 jinja2 的模块

python - distutils索引错误: tuple index out of range

python - 尝试安装 PyQT5 时 Pip 安装卡在 "Preparing Wheel metadata..."

python - 在 Arch Linux 上 pip 安装 mysqlclient

python - 使用Python将特定列数据从CSV导入到不同的MYSQL表中