我无法安装 mysqlclient

时间:2021-04-18 09:54:40

标签: python mysql django

 pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.0.3.tar.gz (88 kB)
Using legacy setup.py install for mysqlclient, since package 'wheel' is not installed.
Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\blackknight\desktop\simpleblog\myenv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Blackknight\\AppData\\Local\\Temp\\pip-install-85jgwelt\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Blackknight\\AppData\\Local\\Temp\\pip-install-85jgwelt\\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\Blackknight\AppData\Local\Temp\pip-record-7y2zgqqa\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\blackknight\desktop\simpleblog\myenv\include\site\python3.8\mysqlclient'
         cwd: C:\Users\Blackknight\AppData\Local\Temp\pip-install-85jgwelt\mysqlclient\
    Complete output (23 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.8
    creating build\lib.win32-3.8\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\_exceptions.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.8\MySQLdb
    creating build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.8\MySQLdb\constants
    running build_ext
    building 'MySQLdb._mysql' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ 
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\blackknight\desktop\simpleblog\myenv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Blackknight\\AppData\\Local\\Temp\\pip-install-85jgwelt\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Blackknight\\AppData\\Local\\Temp\\pip-install-85jgwelt\\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\Blackknight\AppData\Local\Temp\pip-record-7y2zgqqa\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\blackknight\desktop\simpleblog\myenv\include\site\python3.8\mysqlclient' Check the logs for full command output.
WARNING: You are using pip version 20.1.1; however, version 21.0.1 is available.
You should consider upgrading via the 'c:\users\blackknight\desktop\simpleblog\myenv\scripts\python.exe -m pip install --upgrade pip' command.

1 个答案:

答案 0 :(得分:2)

您需要安装 Visual C++ 构建工具。你可以下载它们Here。然后再次尝试安装 mysqlclient

第二个选项您也可以通过二进制安装它。

pip install --only-binary :all: mysqlclient

可选最好升级您的 pip 运行 pip install --upgrade pip