我对python包的安装过程有点恼火。具体来说,安装在dist-packages目录下的包和安装在site-packages目录下的包有什么区别?

我在shell中使用这个命令来安装PIL:

easy_install PIL

然后我运行python并键入:import PIL。但是我得到了这个错误:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named PIL

我从来没有遇到过这样的问题,你觉得呢?

有没有办法找到使用easy_install或pip安装的所有Python PyPI包?我的意思是,不包括发行版工具(在Debian上的apt-get)安装的所有东西。

我在Ubuntu 11上使用easy_install安装lxml有困难。

当我输入$ easy_install lxml时,我得到:

Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.3
Downloading http://lxml.de/files/lxml-2.3.tgz
Processing lxml-2.3.tgz
Running lxml-2.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-7UdQOZ/lxml-2.3/egg-dist-tmp-GacQGy
Building lxml version 2.3.
Building without Cython.
ERROR: /bin/sh: xslt-config: not found

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt 
In file included from src/lxml/lxml.etree.c:227:0:
src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory
compilation terminated.

似乎没有安装libxslt或libxml2。我试着按照http://www.techsww.com/tutorials/libraries/libxslt/installation/installing_libxslt_on_ubuntu_linux.php和http://www.techsww.com/tutorials/libraries/libxml/installation/installing_libxml_on_ubuntu_linux.php上的说明操作,但没有成功。

如果我试着wget ftp://xmlsoft.org/libxml2/libxml2-sources-2.6.27.tar.gz我得到

<successful connection info>
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /libxml2 ... done.
==> SIZE libxml2-sources-2.6.27.tar.gz ... done.
==> PASV ... done.    ==> RETR libxml2-sources-2.6.27.tar.gz ... 
No such file `libxml2-sources-2.6.27.tar.gz'.

如果我先尝试另一个,我会得到。/configure——prefix=/usr/local/libxslt——with-libxml-prefix=/usr/local/libxml2,最终会失败:

checking for libxml libraries >= 2.6.27... configure: error: Could not find libxml2 anywhere, check ftp://xmlsoft.org/.

我尝试了libxml2的2.6.27和2.6.29两个版本,没有什么不同。

不遗余力,我已经成功地完成了sudo apt-get安装libxml2-dev,但这没有改变什么。

Python的easy_install使得安装新包极其方便。然而,据我所知,它没有实现依赖管理器的其他常见特性——列出和删除已安装的包。

找出已安装包的最佳方法是什么,以及删除已安装包的首选方法是什么?如果我手动删除包(例如rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg),是否有任何文件需要更新。鸡蛋或类似的)?

一条推文写道:

不要使用easy_install,除非您 就像捅自己的脸一样。 使用脉冲。

为什么使用pip而不是easy_install?错误不主要在于PyPI和包作者吗?如果作者上传垃圾源tarball(例如:丢失文件,没有setup.py)到PyPI,那么pip和easy_install都将失败。除了外观上的差异之外,为什么Python使用者(就像上面的推文一样)似乎更喜欢pip而不是easy_install?

(让我们假设我们谈论的是来自分发包的easy_install,它由社区维护)