我正在尝试安装mysql-python,我在pip中尝试了两种方法
python -m pip install mysql-python
下载轮子MySQL_python-1.2.5-cp27-none-win_amd64和MySQL_python-1.2.5-cp27-none-win32并尝试使用命令分别安装它们
python -m pip install filename
有没有人知道什么是错的以及如何安装mysql-python?
更新
自写这篇文章以来,我仍然无法使MySQLdb工作,但还尝试了一些其他的东西。
1)我使用Python 3.5 mysql-python是针对Python 2.x的,我应该一直在尝试安装mysqlclient。但是我现在遇到类似的问题,如上面安装带轮子的mysqlclient和只是pip。> pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\teddy\\appdata\\local\\temp\\pip-build-lhtha0\\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\teddy\appdata\local\temp\pip-stnbio-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Users\teddy\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\python27\include -Ic:\python27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(29) : fatal error C1083: Cannot open include file: 'my_config.h': No such file or directory
error: command 'C:\\Users\\teddy\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\teddy\\appdata\\local\\temp\\pip-build-lhtha0\\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\teddy\appdata\local\temp\pip-stnbio-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\teddy\appdata\local\temp\pip-build-lhtha0\mysqlclient\
2)我尝试过安装MySQL连接器C.这没有改变任何东西。
3)我试过让它在Spyder上运行Anaconda附带的IDE
所以任何人都可以提出别的建议
答案 0 :(得分:1)
我终于做到了。为了让它发挥作用,我改变了两件事:
C:\Program Files\MySQL to C:\Program Files (x86)\MySQL