pip install mysql 安装失败了

js2java 发布于 2017/05/03 15:12
阅读 1K+
收藏 0

pip install mysql
Collecting mysql
Collecting MySQL-python (from mysql)
  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 d:\users\administrator\appdata\local\programs\pyt
hon\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\
ADMINI~1\\AppData\\Local\\Temp\\pip-build-71b3lja1\\MySQL-python\\setup.py';f=ge
tattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.cl
ose();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\ADMINI~1\Ap
pData\Local\Temp\tmpf62yovs0pip-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\const
ants
  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\con
stants
  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\consta
nts
  copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.5\MySQLdb\constan
ts
  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\x86_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" -Id:\use
rs\administrator\appdata\local\programs\python\python35\include -Id:\users\admin
istrator\appdata\local\programs\python\python35\include "-IC:\Program Files (x86
)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kit
s\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\inclu
de\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
\\x86_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, mysql
  Running setup.py install for MySQL-python ... error
    Complete output from command d:\users\administrator\appdata\local\programs\p
ython\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users
\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-71b3lja1\\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\ADMINI~
1\AppData\Local\Temp\pip-tdo1m_6q-record\install-record.txt --single-version-ext
ernally-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\con
stants
    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\c
onstants
    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\constan
ts
    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.5\MySQLdb\cons
tants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.5\MySQLdb\const
ants
    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\x86_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" -Id:\u
sers\administrator\appdata\local\programs\python\python35\include -Id:\users\adm
inistrator\appdata\local\programs\python\python35\include "-IC:\Program Files (x
86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows K
its\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\inc
lude\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Progra
m Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd6
4-3.5\Release\_mysql.obj /Zl
    _mysql.c
    _mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': N
o such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\B
IN\\x86_amd64\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "d:\users\administrator\appdata\local\programs\python\python35\python.ex
e -u -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Loc
al\\Temp\\pip-build-71b3lja1\\MySQL-python\\setup.py';f=getattr(tokenize, 'open'
, open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(cod
e, __file__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip
-tdo1m_6q-record\install-record.txt --single-version-externally-managed --compil
e" failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-build-71
b3lja1\MySQL-python\

加载中
1
庄严
庄严

python3.x中已经不支持mysqldb了。

使用pymysql代替(这个我用过,python2也可以用)。安装方式"pip install pymysql“。在站点的__init__.py文件中,我们添加如下代码,就可以和mysqldb完全兼容!

import pymysql
pymysql.install_as_MySQLdb()

 

另外,mysql官方出了个mysql.connector,我没用过这个.

0
旧城的骁珖
旧城的骁珖

找一些需要编译的库时,推荐这里 http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python  

0
mickelfeng
mickelfeng

使用二进制版本。

返回顶部
顶部