简体   繁体   English

pip在Windows 10,Python 3.5上安装MySQL-python?

[英]pip install MySQL-python on windows 10, Python 3.5?

when I try to install pip install MySQL-python on windows 10 I got : 当我尝试在Windows 10上安装pip install MySQL-python时,我得到了:

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\

I'm on windows 10 using python 3.5 and django 1.9 , and I want to connect django to mysql database . 我在Windows 10上使用python 3.5和django 1.9,我想将django连接到mysql数据库。 When I run django server I get : No module named 'MySQLbd' 当我运行django服务器时,我得到:没有名为“ MySQLbd”的模块

MySQL-Python does not support Python 3.x. MySQL-Python不支持Python3.x。 According to the official Django documentation you can use one of the following drivers: 根据Django官方文档,您可以使用以下驱动程序之一:

The Python Database API is described in PEP 249. MySQL has three prominent drivers that implement this API: PEP 249中描述了Python数据库API。MySQL具有三个著名的驱动程序来实现此API:

MySQLdb is a native driver that has been developed and supported for over a decade by Andy Dustman. MySQLdb是本机驱动程序,由Andy Dustman开发并提供了十多年的支持。

mysqlclient is a fork of MySQLdb which notably supports Python 3 and can be used as a drop-in replacement for MySQLdb. mysqlclient是MySQLdb的一个分支,它特别支持Python 3,可以用作MySQLdb的直接替代。 At the time of this writing, this is the recommended choice for using MySQL with Django. 在撰写本文时,这是将MySQL与Django一起使用的推荐选择。

MySQL Connector/Python is a pure Python driver from Oracle that does not require the MySQL client library or any Python modules outside the standard library. MySQL Connector / Python是Oracle提供的纯Python驱动程序,不需要MySQL客户端库或标准库之外的任何Python模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM