我试图安装“pip install mysqlclient”,但每次都失败。尝试了所有其他的方法,但也没用。我该怎么办?

2024-10-01 00:31:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试install pip install mysqlclient,但每次都失败。我也试过pip install --only-binary :all: mysqlclient,但也没用。然后我也下载了whl文件,也没用。我需要帮助。 使用python3.7.2和pip19.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?


Tags: installpippybuildlibrecordusersappdata
1条回答
网友
1楼 · 发布于 2024-10-01 00:31:20

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

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

Fy:很多Python LIBS使用C++在引擎盖下,因此它在微软中安装了Visual C++(Windows上),如错误中提到的。 您可以继续安装微软VisualC++,从herehere

或者,如果mysqlclient后面没有特别的用途,您可以使用这个名为PyMySQL的纯pyython MySQL客户机库(使用这个库不需要安装visualc++)。在

相关问题 更多 >