我目前正在运行 Ubuntu 12.10 并试图让 pymongo 在 python3 下正常工作。我尝试过的事情:
1. apt-get install python-pymongo
2. python setup.py install #from git source
3. easy_install pymongo
4. easy_install pymongo3
5. pip install pymongo
6. pip install pymongo3 #needed a fix in the download script
我还尽可能地在安装之间移除和清洁。
如果我导入 pymongo:
In [1]: import pymongo
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-ec8fdd1cd630> in <module>()
----> 1 import pymongo
/usr/local/lib/python3.2/dist-packages/pymongo-2.4.2_-py3.2-linux-x86_64.egg/pymongo/__init__.py in <module>()
55 return '.'.join(map(str, version_tuple))
56
---> 57 version = get_version_string()
58 """Current version of PyMongo."""
59
/usr/local/lib/python3.2/dist-packages/pymongo-2.4.2_-py3.2-linux-x86_64.egg/pymongo/__init__.py in get_version_string()
51
52 def get_version_string():
---> 53 if isinstance(version_tuple[-1], basestring):
54 return '.'.join(map(str, version_tuple[:-1])) + version_tuple[-1]
55 return '.'.join(map(str, version_tuple))
NameError: global name 'basestring' is not defined
该错误与pymongo FAQ相同,但对我来说,我所在的位置并不重要。
我的理论是pymongo的python2版本误加了python3。