生成“ _mysql”扩展名错误:[WinError 2]系统找不到指定的文件

时间:2018-07-06 23:24:40

标签: python django pycharm

我一直在尝试安装mysqlclient与python通讯,但是我总是在下面收到此错误。我也尝试从命令提示符安装,但是它显示“找不到模块安装工具” 有人可以告诉我怎么了吗?谢谢

我一直在尝试安装mysqlclient与python通讯,但是我总是在下面收到此错误。我也尝试从命令提示符安装,但是它显示“找不到模块安装工具” 有人可以告诉我怎么了吗?谢谢

(venv) C:\Users\kesh\PycharmProjects\SplashSongs>pip3 install mysqlclient
Collecting mysqlclient
Using cached 

https://files.pythonhosted.org/packages/ec
/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/
mysqlclient-1.3.13.tar.gz

Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error

Complete output from command
C:\Users\kesh\PycharmProjects\SplashSongs\venv\Scripts\python.exe -u
-c "import setuptools, 
tokenize;__file__='C:\\Users\\kesh\\AppData\\Local\\Temp\\

pip-install-3qsuf31w\\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\kesh\AppData\Local\Temp\pip-record-6eq7cdv9\install-record.txt
--single-version-externally-managed --compile --install-headers \ Users\kesh\PycharmProjects\SplashSongs\venv\include\site\python3.5\mysqlclient:C:\Users\kesh\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py:261:
 UserWarning: Unknown distribution option:
'long_description_content_type' warnings.warn(msg)

running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
copying _mysql_exceptions.py -> build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\compat.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.5\MySQLdb
creating build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.5\MySQLdb\constants
running build_ext
building '_mysql' extension
error: [WinError 2] The system cannot find the file specified

----------------------------------------
Command "C:\Users\kesh\PycharmProjects\SplashSongs\venv\Scripts\python.exe -u 
-c "import setuptools, 
tokenize;__file__='C:\\Users\\kesh\\AppData\\Local\\Temp\\pip-install- 
3qsuf31w\\msqlclient\\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\kesh\ApData\Local\Temp\pip- 
record-6eq7cdv9\install-record.txt --single-version-externally-managed -- 
compile --install-headers 
C:\Users\kesh\PycharmProjects\SplashSongs\venv\include\site\python3.5\my
sqlclient" failed with error code 1 in C:\Users\kesh\AppData\Local\Temp\pip- 
install-3qsuf31w\mysqlclient\

(venv) C:\Users\kesh\PycharmProjects\SplashSongs>pip3 install mysqlclient
Collecting mysqlclient
Using cached 

https://files.pythonhosted.org/packages/ec
/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/
mysqlclient-1.3.13.tar.gz

Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error

Complete output from command
C:\Users\kesh\PycharmProjects\SplashSongs\venv\Scripts\python.exe -u
-c "import setuptools, 
tokenize;__file__='C:\\Users\\kesh\\AppData\\Local\\Temp\\

pip-install-3qsuf31w\\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\kesh\AppData\Local\Temp\pip-record-6eq7cdv9\install-record.txt
--single-version-externally-managed --compile --install-headers \ Users\kesh\PycharmProjects\SplashSongs\venv\include\site\python3.5\mysqlclient:C:\Users\kesh\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py:261:
 UserWarning: Unknown distribution option:
'long_description_content_type' warnings.warn(msg)

running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
copying _mysql_exceptions.py -> build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\compat.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.5\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.5\MySQLdb
creating build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.5\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.5\MySQLdb\constants
running build_ext
building '_mysql' extension
error: [WinError 2] The system cannot find the file specified

----------------------------------------
Command "C:\Users\kesh\PycharmProjects\SplashSongs\venv\Scripts\python.exe -u 
-c "import setuptools, 
tokenize;__file__='C:\\Users\\kesh\\AppData\\Local\\Temp\\pip-install- 
3qsuf31w\\msqlclient\\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\kesh\ApData\Local\Temp\pip- 
record-6eq7cdv9\install-record.txt --single-version-externally-managed -- 
compile --install-headers 
C:\Users\kesh\PycharmProjects\SplashSongs\venv\include\site\python3.5\my
sqlclient" failed with error code 1 in C:\Users\kesh\AppData\Local\Temp\pip- 
install-3qsuf31w\mysqlclient\

1 个答案:

答案 0 :(得分:2)

转到https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient并下载适用于您的python版本的预编译mysqlclient库。例如,如果您使用的是python 3.6 32位版本,请下载

  

mysqlclient‑1.3.13‑cp36‑cp36m‑win32.whl

然后从命令提示符或pycharm终端(如果要为项目的虚拟环境安装,则为pycharm终端)执行

pip install "Path for the downloaded .whl file"

那应该没有问题地安装mysqlclient。