如何在使用 Python 2.6 的 Linux 系统上通过 pip/virtualenv for Python 2.5 安装 MySQL-python?
我正在尝试为 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
?
I am trying to set up a virtualenv for a Django project. It needs MySQL-python. I'm trying to replicate the production environment, which uses Python 2.5. My Ubuntu desktop has Python 2.5. I can install the Python 2.5 virtualenv with virtualenv --python=/usr/bin/python2.5 ...
. However when I try to pip install MySQL-python
, I get this output:
$ 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
I have installed the python-dev
Ubuntu deb package, but that's for Python 2.6.
How else can I get MySQL-python
installed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在 Ubuntu 机器上也遇到了同样的问题。在通过 pip 安装 MySQL-python 之前,我需要使用以下命令从源代码编译模块和依赖项:
请参阅这篇文章 - http://theviceprogrammer.com/?p=238
I had this same problem on an Ubuntu box. Prior to installing MySQL-python via
pip
, I needed to compile the module and dependencies from source using the following command:see this article - http://theviceprogrammer.com/?p=238
实际上,找到了一个解决方案,我启用了 Dead Snakes - old python version 存储库,然后我可以
aptitude install python2.5-dev
,然后pip install MySQL-python
工作Actually, found a solution, I enabled the Dead Snakes - old python version repository, then I could
aptitude install python2.5-dev
, and thenpip install MySQL-python
worked您可以使用 apt-get,而不是使用 pip 或 easy_install:
在 Ubuntu 12.04 w/ Python 2.5 上,我不需要按照 Adam 的回复从源代码中要求
Instead of using pip or easy_install, you can use apt-get:
Requiring from source as per adam's reply wasn't require for me, on Ubuntu 12.04 w/ Python 2.5