Python 2.7 和MySQL Ubuntu 安装 - ZipImportError

发布于 2024-11-04 11:43:36 字数 977 浏览 0 评论 0原文

我已经在我的 Ubuntu 10 上安装了 MySQL5。 我已经使用这些命令安装了 python2.7:

$ tar xfz Python-2.7.1.tgz
$ cd Python-2.7.1
$ ./configure && make && sudo make install
$ sudo rm /usr/bin/python
$ sudo ln -s /usr/local/python2.7 /usr/bin/python

我读到我还需要 mysqldb。所以我尝试安装 mysql-python:

$ tar xfz MySQL-python-1.2.1.tar.gz
$ cd MySQL-python-1.2.1
$ python setup.py build
$ sudo python setup.py install

并得到:

Traceback (most recent call last):
  File "setup.py", line 17, in <module>
    from setuptools import setup, find_packages
ImportError: No module named setuptools

尝试安装 setuptools:

$ sh setuptools-0.6c11-py2.7.egg

并得到:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available

zlib 不应该与默认的 python 安装捆绑在一起吗?

I already have MySQL5 installed on my Ubuntu 10.
I have installed python2.7 with these commands:

$ tar xfz Python-2.7.1.tgz
$ cd Python-2.7.1
$ ./configure && make && sudo make install
$ sudo rm /usr/bin/python
$ sudo ln -s /usr/local/python2.7 /usr/bin/python

I read that I need mysqldb also. So I tried to install mysql-python:

$ tar xfz MySQL-python-1.2.1.tar.gz
$ cd MySQL-python-1.2.1
$ python setup.py build
$ sudo python setup.py install

And got:

Traceback (most recent call last):
  File "setup.py", line 17, in <module>
    from setuptools import setup, find_packages
ImportError: No module named setuptools

Tried to install setuptools:

$ sh setuptools-0.6c11-py2.7.egg

And got:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available

Isn't zlib supposed to be bundled with default python installation ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

月亮是我掰弯的 2024-11-11 11:43:36

在构建 Python 之前,您忘记安装 libz-dev 或 zlib-dev 之类的东西。

You forgot to install libz-dev or zlib-dev or whatnot before building Python.

奢望 2024-11-11 11:43:36

当您在 python 文件夹中运行此命令时,

$ ./configure && make && sudo make install

您实际上正在做的是从源代码构建 pythonn 然后安装。所以基本上只需重新运行再次安装 python 的过程即可。

你可以先

sudo apt-get remove python

When you run this command in python folder

$ ./configure && make && sudo make install

what you are actually doing is building the the pythonn from source and then installing. So just basically re-run the process for installing python again .

You can first

sudo apt-get remove python
痴情换悲伤 2024-11-11 11:43:36

您不必自己编译Python。这是最简单解决方案:

  1. ActivePython 安装到 /opt/ActivePython-2.7
  2. 打开终端并运行 /opt/ActivePython-2.7/bin/pypm install mysql-python

You don't have to compile Python yourself. Here's the simplest solution:

  1. Install ActivePython to /opt/ActivePython-2.7
  2. Open Terminal and run /opt/ActivePython-2.7/bin/pypm install mysql-python
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文