1

CentOS 5.8 附带 Python 2.4.3。我使用命令安装了 pymongo: sudo pip install pymongo (在安装 python-pip 后使用 easy_install 安装 pip ...典型的 CentOS 后,开箱即用没有任何效果)。

安装似乎工作,我收到消息:

    Successfully installed pymongo
    Cleaning up...

然后,当我运行 import pymongo 时,我得到了这个:

ImportError:没有名为 pymongo 的模块

我遵循标准的 pymongo 安装程序,所以 pymongo 绝对不能在 CentOS 上运行。任何人都知道使此工作的解决方法吗?似乎又一次,需要一个 hack 来使 CentOS 支持所有其他 Linux 发行版开箱即用的基本功能......

4

1 回答 1

1

Since you didn't specify you need to use the default CentOS Python install, I would highly recommend using virtualenv to get the support you want. CentOS requires that old version of Python, and we have to work around it at my business as well.

Grab the latest Python, and build from source. Make sure any SSL devel libraries are installed through Yum.

./configure --prefix=/home/user/custompython
make && make install

Grab virtualenv.py from https://raw.github.com/pypa/virtualenv/master/virtualenv.py and run that script from your custom python install

/home/user/custompython/bin/python virtualenv.py -P /home/user/custompython/bin/python /home/user/pythonENV
export PYTHON_HOME=/home/user/pythonENV/
export PATH=/home/user/pythonENV/bin/:$PATH
pip install pymongo

Of course, adding the path modifications to .bashrc is helpful. Now you can install anything you want without worrying about the very old 2.4.3 that CentOS ships with. This is the exact setup I have with our CentOS 5.8 system, and it is very helpful.

于 2012-06-12T00:07:56.127 回答