0

我安装了 python 最新版本python3.10.0和 django 版本 3.2.8。我尝试通过pip install mysqlclient在命令提示符中使用命令来安装 mysqlclient,但它显示如下错误:

 Building wheel for mysqlclient (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'F:\django\job\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\IIITK2\\AppData\\Local\\Temp\\pip-install-ja9ipfah\\mysqlclient_08057cd8bc0f44f5bca353c6775cb063\\setup.
py'"'"'; __file__='"'"'C:\\Users\\IIITK2\\AppData\\Local\\Temp\\pip-install-ja9ipfah\\mysqlclient_08057cd8bc0f44f5bca353c6775cb063\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io
.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\IIITK2\AppData\Local\Temp\pip-wheel-p39k
z555'
   cwd: C:\Users\IIITK2\AppData\Local\Temp\pip-install-ja9ipfah\mysqlclient_08057cd8bc0f44f5bca353c6775cb063\
  Complete output (23 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.10
  creating build\lib.win-amd64-3.10\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win-amd64-3.10\MySQLdb
  copying MySQLdb\_exceptions.py -> build\lib.win-amd64-3.10\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win-amd64-3.10\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win-amd64-3.10\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win-amd64-3.10\MySQLdb
  copying MySQLdb\release.py -> build\lib.win-amd64-3.10\MySQLdb
  copying MySQLdb\times.py -> build\lib.win-amd64-3.10\MySQLdb
  creating build\lib.win-amd64-3.10\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.10\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.10\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.10\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.10\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.10\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.10\MySQLdb\constants
  running build_ext
  building 'MySQLdb._mysql' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

谁能说一个解决方案?

4

2 回答 2

1

现在可用 mysqlclient 2.1.0。mysqlclient 2.0.3 不支持 python 3.10 版本。

立即运行此命令 pip install mysqlclient

于 2021-11-19T12:38:57.650 回答
0

Ubuntu 需要这个 OS 包mysqlclient来安装 python 包:

sudo apt install libmysqlclient-dev
于 2022-02-14T09:26:38.267 回答