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

发布于 2024-10-28 22:23:05 字数 1221 浏览 1 评论 0原文

我正在尝试为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

染墨丶若流云 2024-11-04 22:23:05

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

sudo apt-get build-dep python-mysqldb

请参阅这篇文章 - 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:

sudo apt-get build-dep python-mysqldb

see this article - http://theviceprogrammer.com/?p=238

假装爱人 2024-11-04 22:23:05

实际上,找到了一个解决方案,我启用了 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 then pip install MySQL-python worked

明明#如月 2024-11-04 22:23:05

您可以使用 apt-get,而不是使用 pip 或 easy_install:

sudo apt-get install python-mysqldb

在 Ubuntu 12.04 w/ Python 2.5 上,我不需要按照 Adam 的回复从源代码中要求

Instead of using pip or easy_install, you can use apt-get:

sudo apt-get install python-mysqldb

Requiring from source as per adam's reply wasn't require for me, on Ubuntu 12.04 w/ Python 2.5

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文