pip和安装mysql-python

3

我正在尝试使用pip通过install MySQL-Python安装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操作系统。


尝试这个:https://dev59.com/g18d5IYBdhLWcg3waxgp - uma
1个回答

2

看起来你的pip版本已经过时了。

  1. 首先执行命令 python -m pip install --upgrade pip 更新pip

  2. 然后使用你下载的wheel包,如果你的路径中有python3,则执行python3 -m pip install [.whl_location],否则请进入python3文件夹并执行同样的命令。

希望这可以帮到你。


升级提示我已经是最新版本。而输入“-m pip install C:\Users\Rasmus\Downloads\MySQL_python-1.2.5-cp27-none-win_amd64.whl”则显示python3不被识别为内部或外部命令。 - vandelay
你需要导航到python3文件夹并输入python,因为在你的情况下这是.exe的名称。 - Ganesh Kathiresan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接