2016-12-24 182 views
1

我正在使用mongoengine ORM,但我最近將mongoengie升級到了0.9,這讓我將pymongo降級到了2.8版本。每當我嘗試使用的代碼ImportError:無法導入名稱UNAUTHORIZED_CODES

from mongoengine import * 

connect('dbName') 

我得到這個錯誤

/usr/bin/python2.7 /root/Documents/Projects/BetCafe/main/tester.py 
Traceback (most recent call last): 
File "/root/Documents/Projects/BetCafe/main/tester.py", line 1, in <module> 
from mongoengine import * 

File "/usr/local/lib/python2.7/dist-packages/mongoengine/__init__.py", line 3, in <module> 
import fields 
File "/usr/local/lib/python2.7/dist-packages/mongoengine/fields.py", line 19, in <module> 
import gridfs 
File "/usr/lib/python2.7/dist-packages/gridfs/__init__.py", line 32, in <module> 
from pymongo.common import UNAUTHORIZED_CODES, validate_string  
ImportError: cannot import name UNAUTHORIZED_CODES 

Process finished with exit code 1 

我試圖重新安裝兩個pymongo和mongoengine要對數據庫的連接,但他們都沒有工作

任何幫助將不勝感激。

+0

升級pymongo?升級網格? – Evert

回答

2

您似乎有一個新版本的GridFS(它需要UNAUTHORIZED_CODES常量,在PyMongo since version 3.1中),而您的降級版本的Pymongo 2.8版本。

嘗試從/usr/lib/python2.7/dist-packages/刪除目錄gridfs,bsonpymongo,然後再次安裝PyMongo。

相關問題