繁体   English   中英

如何在具有Python 2.6的Linux系统上通过pip / virtualenv for Python 2.5安装MySQL-python?

[英]How can I install MySQL-python via pip/virtualenv for Python 2.5 on a Linux system with Python 2.6?

我正在尝试为Django项目设置virtualenv。 它需要MySQL-python。 我正在尝试复制使用Python 2.5的生产环境。 我的Ubuntu桌面具有Python 2.5。 我可以使用virtualenv --python=/usr/bin/python2.5 ...安装Python 2.5 virtualenv。 但是,当我尝试pip install MySQL-python ,得到以下输出:

$ pip install MySQL-python
Downloading/unpacking MySQL-python
  Running setup.py egg_info for package MySQL-python
    warning: no files found matching 'MANIFEST'
    warning: no files found matching 'ChangeLog'
    warning: no files found matching 'GPL'
Installing collected packages: MySQL-python
  Running setup.py install for MySQL-python
    building '_mysql' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/usr/include/python2.5 -c _mysql.c -o build/temp.linux-i686-2.5/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -DUNIV_LINUX -DUNIV_LINUX
    In file included from _mysql.c:29:
    pymemcompat.h:10: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1

我已经安装了python-dev Ubuntu deb软件包,但这是针对python 2.6的。

我还能如何安装MySQL-python

我在Ubuntu盒子上也遇到了同样的问题。 在通过pip安装MySQL-python之前,我需要使用以下命令从源代码编译模块和依赖项:

sudo apt-get build-dep python-mysqldb

看到这篇文章-http://theviceprogrammer.com/?p=238

实际上,找到了一个解决方案,我启用了Dead Snakes-旧的python版本存储库,然后可以aptitude install python2.5-dev ,然后pip install MySQL-python工作

除了使用pip或easy_install,还可以使用apt-get:

sudo apt-get install python-mysqldb

在我使用Ubuntu 2.5的Ubuntu 12.04上,不需要按adam的答复从源进行请求

暂无
暂无

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

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