2016-04-03 234 views
0

的MySQL-python的,当我尝试安装PIP在Windows上安装10在MySQL-python的我:PIP在Windows上安装

C:\Users\ghina>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:\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ghina\\AppData\\Local\\Temp\\pip-build-eo59erqx\\MySQL-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\ghina\AppData\Local\Temp\pip-b4pe3d_p-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 
    error: Unable to find vcvarsall.bat 

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

我在使用Python 3.5的窗口10和Django的1.9,我想将django连接到mysql数据库。当我运行django服务器时,我得到:没有名为'MySQLbd'的模块

+0

python 3.x的替代方法是什么? – ghina

回答

2

MySQL-Python不支持Python 3.x.根据官方Django documentation您可以使用以下驱动程序之一:

Python数据库API在PEP描述249. MySQL有实现这个API三位著名车手:

MySQLdb是一个本地驱动程序,已由Andy Dustman在过去十年中为 开发和支持。

mysqlclient是MySQLdb的一个分支,其中 显着支持Python 3并可用作MySQLdb的插入替换 。在撰写本文时,这是推荐使用MySQL和Django的选择 。

MySQL Connector/Python是Oracle的一个纯Python 驱动程序,它不需要MySQL客户端库或 标准库之外的任何Python模块。