2016-04-03 242 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模塊。