Django:Mysql-python安装错误

时间:2014-01-30 23:43:20

标签: python django mysql-python

当尝试为Django安装requirements.txt时,我在尝试安装Mysql-python时遇到以下错误

Traceback (most recent call last):

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

  File "/home/abercrrl/.virtualenvs/django_at/build/MySQL-python/setup.py", line 7, in <module>

    use_setuptools()

  File "distribute_setup.py", line 145, in use_setuptools

    return _do_download(version, download_base, to_dir, download_delay)

  File "distribute_setup.py", line 125, in _do_download

    _build_egg(egg, tarball, to_dir)

  File "distribute_setup.py", line 116, in _build_egg

    raise IOError('Could not build the egg.')

IOError: Could not build the egg.

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/abercrrl/.virtualenvs/django_at/build/MySQL-python
Storing debug log for failure in /home/abercrrl/.pip/pip.log

请注意,我尝试过:

pip install --upgrade setuptools 

Setuptools已经是最新的


编辑:

我修改了以下命令以匹配我的位置:

echo "mysql_config = /usr/bin/mysql_config" >> ~/.virtualenvs/django_at/build/MySQL-python/site.cfg

我必须创建构建和MySQL-python目录才能使用。命令运行正常,但现在我现在得到这个: https://gist.github.com/rlabercrombie/8725074

1 个答案:

答案 0 :(得分:5)

你必须安装mysql dev和所有必需的库才能构建mysql-python:sudo apt-get install build-essential python-dev libmysqlclient-dev python-mysqldb。有关详细信息,请参阅http://mysql-python.blogspot.no/2012/11/is-mysqldb-hard-to-install.htmlhttps://stackoverflow.com/a/7461662/3219121