【问题标题】:I am trying to install "pip install mysqlclient" and it fails everytime. Tried all other things but also didnt work. What should I do?我正在尝试安装“pip install mysqlclient”,但每次都失败。尝试了所有其他的东西,但也没有奏效。我该怎么办?
【发布时间】:2019-07-10 10:52:31
【问题描述】:

我正在尝试install pip install mysqlclient,但每次都失败。我也试过pip install --only-binary :all: mysqlclient 也没有工作。然后我还下载了 whl 文件,也没有工作。我需要帮助。 使用 python 3.7.2 和 pip 19.0.2 版本。 这是弹出的整个错误:

Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
  Complete output from command c:\users\vertig~1.0\envs\mypro\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\VERTIG~1.0\\AppData\\Local\\Temp\\pip-install-b81i8gmq\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\VERTIG~1.0\AppData\Local\Temp\pip-record-6s1gmot9\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\vertig~1.0\envs\mypro\include\site\python3.7\mysqlclient:
  running install
  running build
  running build_py
  creating build
  creating build\lib.win32-3.7
  creating build\lib.win32-3.7\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
  creating build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
  running build_ext
  building 'MySQLdb._mysql' extension
  error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

  ----------------------------------------
Command "c:\users\vertig~1.0\envs\mypro\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\VERTIG~1.0\\AppData\\Local\\Temp\\pip-install-b81i8gmq\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\VERTIG~1.0\AppData\Local\Temp\pip-record-6s1gmot9\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\vertig~1.0\envs\mypro\include\site\python3.7\mysqlclient" failed with error code 1 in C:\Users\VERTIG~1.0\AppData\Local\Temp\pip-install-b81i8gmq\mysqlclient\```

So any ideas where the error is getting?

【问题讨论】:

  • 由于您是新的贡献者,我建议您始终将错误消息与您的问题一起发布。否则没有人能真正帮助你。更好地编辑您的问题并添加您收到的错误消息。还要添加你正在使用的 pip 和 mysql 版本。
  • 如果可以,安装 64 位 Python 3.7.x。 Windows 上有一个 64 位 Python 3.7 的官方轮子。如果您使用 32 位 Python,则必须从源代码(这可能很棘手)或 install an unofffical wheel 安装。
  • @Alasdair 我已经安装了 64 it python 并且还下载了 64 位 wheel 文件。并且还在 cmd 中尝试过这个:pip install mysqlclient-1.4.2-cp37-cp37m-win_amd64 它显示了这个:Could not find a version that satisfies the requirement mysqlclient-1.4.2-cp37-cp37m-win_amd64 (from versions: ) No matching distribution found for mysqlclient-1.4.2-cp37-cp37m-win_amd64
  • @hackSlanger 请问如何在cmd中查看我的mysql版本
  • 如果你想安装一个下载的轮子,那么你需要包含.whl的完整文件名。

标签: python mysql django python-3.x pip


【解决方案1】:

检查您的系统上是否安装了 MySQL。

在 Mac 上:

brew install mysql

使用 APT 安装(例如 Ubuntu):

sudo apt install mysql-server

或使用安装程序安装:https://dev.mysql.com/downloads/installer/

【讨论】:

    【解决方案2】:

    错误:需要 Microsoft Visual C++ 14.0。用“微软 Visual C++ 构建工具”:https://visualstudio.microsoft.com/downloads/

    从错误消息中可以清楚地看出问题出在您的机器上安装 C++。

    仅供参考:许多 Python 库在后台使用 C++,因此必须安装 Microsoft Visual C++(在 Windows 上),如错误中所述。 您可以继续从herehere 安装Microsoft Visual C++

    否则,如果 mysqlclient 后面没有特殊用途,您可以使用这个名为 PyMySQL 的纯 pyython MySQL 客户端库(您无需安装 Visual c++ 即可使用此库)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-08
      • 2014-09-21
      • 2019-11-06
      • 2022-11-06
      相关资源
      最近更新 更多