无法在os x上安装MySQL-python

时间:2016-02-20 01:55:50

标签: python mysql django python-2.7 python-3.x

我正在尝试在OS X 10.11.3上使用Django的MySQL数据库但是当我尝试“pip install MySQL-python”时它给了我这个错误:

Collecting MySQL-python   Using cached MySQL-python-1.2.5.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/0q/24f40xt52fg_xbjz5drz_m2r0000gn/T/pip-build-8ms1ni7b/MySQL-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/private/var/folders/0q/24f40xt52fg_xbjz5drz_m2r0000gn/T/pip-build-8ms1ni7b/MySQL-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'

    ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/0q/24f40xt52fg_xbjz5drz_m2r0000gn/T/pip-build-8ms1ni7b/MySQL-python

我尝试安装ConfigParser,我的系统上安装了MySQL python连接器。

以下是我的项目详情:

Django 1.9.2
Python 3.5
OS X 10.11.3
IDE PyCharm
虚拟环境myvenv

我已经搜索过互联网,几乎尝试了所有使用MySQL和Django的方法,但是我几个小时都失败了。请指导我这个

1 个答案:

答案 0 :(得分:0)

看起来你正在尝试在Python 3上安装Python 2.X only驱动程序。文档建议使用mysqlclient:

https://docs.djangoproject.com/en/1.9/ref/databases/#mysql-db-api-drivers

包含安装说明的mysqlclient GitHub页面,包括您可能需要的先决条件:

https://github.com/PyMySQL/mysqlclient-python

祝你好运!