Python3.4无法安装mysql-python

时间:2015-01-02 21:06:50

标签: python mysql django python-3.x

# pip3.4 install mysql-python
  Downloading/unpacking mysql-python
  Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
  Running setup.py (path:/tmp/pip_build_root/mysql-python/setup.py) egg_info for package mysql-python
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/mysql-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/tmp/pip_build_root/mysql-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/mysql-python/setup.py", line 13, in <module>

    from setup_posix import get_config

  File "/tmp/pip_build_root/mysql-python/setup_posix.py", line 2, in <module>

    from ConfigParser import SafeConfigParser

ImportError: No module named 'ConfigParser'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/mysql-python
Storing debug log for failure in /root/.pip/pip.log

4 个答案:

答案 0 :(得分:19)

MySQL-python 1.2.5不支持Python 3. Django 1.7 docs推荐使用fork mysqlclient

答案 1 :(得分:6)

解决:

 pip3.4 install --allow-external mysql-connector-python 

编辑settings.py

'ENGINE': 'mysql.connector.django',

答案 2 :(得分:0)

在Centos下:yum install mysql-devel pip3安装mysqlclient

答案 3 :(得分:-4)

在Ubuntu或Debian上,只需要sudo apt-get install python-mysqldb。它对我有用