step 1:
找到安装源pymongo.tar.gz,解压之后python setup.py install就可以了
step 2:
安装之后发现一个问题,如果C调用python插件的方式,依然无法import pymongo
具体的原因:
python console中sys.path中包含pymongo
>>> import sys
>>> sys.path
['', '/usr/lib64/python2.6/site-packages/pymongo-2.7.2-py2.6-linux-x86_64.egg', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']
而C调用python插件的方式,sys.path仅包含
['/usr/lib64/python26.zip', '/usr/lib64/python2.6/', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/local/bin/', './']
一个简单的解决方法就是将pymongo-2.7.2-py2.6-linux-x86_64.egg下的所有组件拷贝到/usr/lib64/python2.6/
包括bson、pymongo、gridfs
换言之,直接解压pymongo.tar.gz并将对应的三个组件拷贝到python-packeages目录,无论python还是C调用python组件都可以导入pymongo