python - pip 和安装 mysql-python

标签 python

我正在尝试使用 pip install MySQL-Python 通过 pip 安装 MySQL-Python。但是我收到了一些错误消息。这是控制台日志:

C:\WINDOWS\system32>pip install mysql-python
Collecting mysql-python
  Using cached MySQL-python-1.2.5.zip
Building wheels for collected packages: mysql-python
  Running setup.py bdist_wheel for mysql-python ... error
  Complete output from command c:\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Rasmus\\AppData\\Local\\Temp\\pip-build-cfm09c14\\mysql-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d C:\Users\Rasmus\AppData\Local\Temp\tmps09l9dk_pip-wheel- --python-tag cp35:
  running bdist_wheel
  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\converters.py -> build\lib.win-amd64-3.5\MySQLdb
  copying MySQLdb\connections.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\CR.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\ER.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
  copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.5\MySQLdb\constants
  running build_ext
  building '_mysql' extension
  creating build\temp.win-amd64-3.5
  creating build\temp.win-amd64-3.5\Release
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\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:\anaconda3\include -Ic:\anaconda3\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\NETFXSDK\4.6.1\include\um" "-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.win-amd64-3.5\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\\amd64\\cl.exe' failed with exit status 2

  ----------------------------------------
  Failed building wheel for mysql-python
  Running setup.py clean for mysql-python
Failed to build mysql-python
Installing collected packages: mysql-python
  Running setup.py install for mysql-python ... error
    Complete output from command c:\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Rasmus\\AppData\\Local\\Temp\\pip-build-cfm09c14\\mysql-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\Rasmus\AppData\Local\Temp\pip-u6i7y7az-record\install-record.txt --single-version-externally-managed --compile:
    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\converters.py -> build\lib.win-amd64-3.5\MySQLdb
    copying MySQLdb\connections.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\CR.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\ER.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
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.5\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    creating build\temp.win-amd64-3.5
    creating build\temp.win-amd64-3.5\Release
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\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:\anaconda3\include -Ic:\anaconda3\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\NETFXSDK\4.6.1\include\um" "-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.win-amd64-3.5\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\\amd64\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Rasmus\\AppData\\Local\\Temp\\pip-build-cfm09c14\\mysql-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\Rasmus\AppData\Local\Temp\pip-u6i7y7az-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Rasmus\AppData\Local\Temp\pip-build-cfm09c14\mysql-python\

我尝试从 http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python 下载这两个 whl 文件并“手动”安装它们但他们给出了错误:

C:\WINDOWS\system32>pip install C:\Users\Rasmus\Downloads\MySQL_python-1.2.5-cp27-none-win_amd64.whl
MySQL_python-1.2.5-cp27-none-win_amd64.whl is not a supported wheel on this platform.

我用的是 python 3.5 和 windows 10。

最佳答案

您的 pip 版本似乎已过时。

  1. 所以首先执行 python -m pip install --upgrade pip

  2. 然后使用您下载的 wheel,但是如果 python3 在您的路径中,则执行 python3 -m pip install [.whl_location],否则导航到 python3 文件夹并执行相同的操作。

希望这对您有所帮助。

关于python - pip 和安装 mysql-python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38948496/

相关文章:

python - 静态继承python

Python 和 Google Sheets - 检查数据在哪一行

Python:读取多个 CSV 文件,并将每个文件分配给不同的变量

Python - 函数更改输入列表,虽然我做了一个副本

python - 是否可以发送 'OptionParser' 对象作为输入参数来运行导入的 python 模块的 main ?

c++ - 从 boost::python 中的 kwargs 中提取参数

python - Python 中的模式匹配、元组和乘法

python - 使用 Django 将 Unicode 子类存储到 MySQL

python - 使用lmfit时“ValueError: The input contains nan values”

python - OCR应用前图像清洗