python - 我正在尝试使用 pip 安装 MySQL 库,但收到一个奇怪的错误

标签 python mysql pip

在 CMD 中,我输入 pip install MySQL-python。这是输出错误:

    Collecting MySQL-python
  Using cached MySQL-python-1.2.5.zip
Installing collected packages: MySQL-python
  Running setup.py install for MySQL-python ... error
    Complete output from command c:\users\paint\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\paint\\AppData\\Local\\Temp\\pip-build-r4io9vrf\\MySQL-python\\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\paint\AppData\Local\Temp\pip-ltci1jrf-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.6
    copying _mysql_exceptions.py -> build\lib.win32-3.6
    creating build\lib.win32-3.6\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.6\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.6\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.6\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.6\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.6\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.6\MySQLdb
    creating build\lib.win32-3.6\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.6\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.6\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.6\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.6\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.6\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.6\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.6\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    creating build\temp.win32-3.6
    creating build\temp.win32-3.6\Release
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\users\paint\appdata\local\programs\python\python36-32\include -Ic:\users\paint\appdata\local\programs\python\python36-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win32-3.6\Release\_mysql.obj /Zl
    _mysql.c
    _mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\users\paint\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\paint\\AppData\\Local\\Temp\\pip-build-r4io9vrf\\MySQL-python\\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\paint\AppData\Local\Temp\pip-ltci1jrf-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\paint\AppData\Local\Temp\pip-build-r4io9vrf\MySQL-python\

我读了很多书,但找不到任何这样的日志。感谢您的帮助!

最佳答案

先尝试python installwheel,然后安装MySQL包 pip install mysqlclient.whl

关于python - 我正在尝试使用 pip 安装 MySQL 库,但收到一个奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48254484/

相关文章:

python - 如何快速绘制 10000+ 二维图形对象?

pip - 找不到满足 ctypes 要求的版本(来自版本 : ) No matching distribution found for ctypes

当脚本通过 Launchd 运行时,Git Push 不起作用

c# - 如何在c#中将DataGridView多行数据保存到MySQL数据库

python - Miniconda 在每次环境更新时都会重新下载包

ruby - package.json (javascript npm) 或 requirements.txt (python pip) 等同于 ruby

python - OpenCV错误:在cv::imshow中断言失败(size.width> 0 && size.height> 0)-Python

python - 导入错误:没有名为tinydb的模块

python - 如何在 Python 中拆分字典数组?

mysql 查询插入一些与其 id 连接的值