如何获得在计算机上安装的Python模块列表?

我在安装psycopg2时遇到了麻烦。当我尝试pip安装psycopg2时,我得到以下错误:

Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH

or specify the full executable path with the option:



    python setup.py build_ext --pg-config /path/to/pg_config build ...



or with the pg_config option in 'setup.cfg'.

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/psycopg2

但问题是pg_config实际上在我的PATH中;它运行起来没有任何问题:

$ which pg_config
/usr/pgsql-9.1/bin/pg_config

我尝试将pg_config路径添加到setup.cfg文件中,并使用我从他们的网站(http://initd.org/psycopg/)下载的源文件构建它,我得到了以下错误消息!

Error: Unable to find 'pg_config' file in '/usr/pgsql-9.1/bin/'

但它确实在那里!!

我对这些错误感到困惑。有人能帮忙吗?

顺便说一下,我sudo所有的命令。而且我使用的是RHEL 5.5。

问题是:

我有一个requirements.txt文件,看起来像:

BeautifulSoup==3.2.0
Django==1.3
Fabric==1.2.0
Jinja2==2.5.5
PyYAML==3.09
Pygments==1.4
SQLAlchemy==0.7.1
South==0.7.3
amqplib==0.6.1
anyjson==0.3
...

我有一个本地归档目录,包含所有包和其他包。

我用

bin/virtualenv testing

激活后,我尝试根据本地存档目录中的requirements.txt安装软件包。

source bin/activate
pip install -r /path/to/requirements.txt -f file:///path/to/archive/

我得到的一些输出似乎表明安装正常:

Downloading/unpacking Fabric==1.2.0 (from -r ../testing/requirements.txt (line 3))
  Running setup.py egg_info for package Fabric
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no files found matching 'fabfile.py'
Downloading/unpacking South==0.7.3 (from -r ../testing/requirements.txt (line 8))
  Running setup.py egg_info for package South
....

但后来的检查显示,没有一个软件包安装正确。我无法导入包,并且在virtualenv的站点包目录中找不到包。那么到底出了什么问题?

昨天我花了大部分时间寻找安装pip(Python包管理器)的明确答案。我找不到好的解决方案。

如何安装?

我正在尝试安装MySQL_python的1.2.2版本,使用使用--no site packages选项创建的新virtualenv。PyPi中显示的当前版本是1.2.3。有没有办法安装旧版本?我尝试过:

pip install MySQL_python==1.2.2

但是,安装后,它仍然在站点包中显示MySQL_python-1.2.3-py2.6.egg-info。这是这个包特有的问题,还是我做错了什么?

是否可以使用pip一次性升级所有Python包?

注意:官方问题跟踪器上对此有一个功能请求。

pip是easyinstall的替代品。但是我应该在Windows上使用easy_install安装pip吗?有更好的方法吗?