【问题标题】:Django: Mysql-python installation errorDjango:Mysql-python安装错误
【发布时间】:2014-02-23 13:05:55
【问题描述】:

尝试为 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

我确实必须创建 build 和 MySQL-python 目录才能使其正常工作。该命令运行良好,但是现在我得到了这个: https://gist.github.com/rlabercrombie/8725074

【问题讨论】:

  • 您应该提供更多信息,然后粘贴文件 /home/abercrrl/.pip/pip.log。你试过手动做pip install MySQL-python吗?
  • This answer 已解决该问题。
  • @caesarsol 整个文件太大,无法在此处发布。有没有发布大量代码的好方法?手动 pip install MySQL-python 产生同样的错误
  • @richard008:用户 matagus 给了你我认为正确的答案。下次粘贴日志文件的最后几行,或者粘贴到gist.github.com或者pastebin.com
  • @caesarsol 我更新了我的帖子,但出现了另一个错误。

标签: python django mysql-python


【解决方案1】:

您必须安装 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

【讨论】:

  • 快速提问。 mysql当前安装在服务器上,这会覆盖任何现有文件吗?
  • 没有。它只安装 python 和编译器相关的库
  • 感谢第一个链接,帮了很多忙,我错过了 mysql 开发库。另外,如果有任何 Fedora 用户出现,那就是 yum install mysql-devel
猜你喜欢
  • 2019-08-16
  • 2016-04-19
  • 2016-04-28
  • 2014-11-23
  • 2016-11-27
  • 1970-01-01
  • 2014-06-10
  • 2017-07-31
相关资源
最近更新 更多