Python 2.7 和MySQL Ubuntu 安装 - ZipImportError
我已经在我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在构建 Python 之前,您忘记安装 libz-dev 或 zlib-dev 之类的东西。
You forgot to install libz-dev or zlib-dev or whatnot before building Python.
当您在 python 文件夹中运行此命令时,
您实际上正在做的是从源代码构建 pythonn 然后安装。所以基本上只需重新运行再次安装 python 的过程即可。
你可以先
When you run this command in python folder
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
您不必自己编译Python。这是最简单解决方案:
/opt/ActivePython-2.7
/opt/ActivePython-2.7/bin/pypm install mysql-python
You don't have to compile Python yourself. Here's the simplest solution:
/opt/ActivePython-2.7
/opt/ActivePython-2.7/bin/pypm install mysql-python