Python Mogo ImportError:无法导入名称连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29690786/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python Mogo ImportError: cannot import name Connection
提问by 888
Can't figure out why this is not working.
无法弄清楚为什么这不起作用。
mogo==0.2.4
mogo==0.2.4
File "/Users/Sam/Envs/AdiosScraper/lib/python2.7/site-packages/mogo/connection.py", line 3, in <module>
from pymongo import Connection as PyConnection
ImportError: cannot import name Connection
回答by thegreenogre
from mogo import connect as PyConnection
pymongo.Connectionis deprecated use MongoClientinstead. In terms of use they are very similar.
pymongo.Connection已弃用MongoClient。在使用方面,它们非常相似。
回答by NoobEditor
i had same problem and too many files had the import, so, i couldn't risk changing the import- (didn't knew exactly where all it is mentioned).
我遇到了同样的问题,并且导入了太多文件,因此,我不能冒险更改import- (不知道所有提到的确切位置)。
I just downgraded pymongo:
我刚刚降级pymongo:
sudo pip install pymongo==2.7.2
and it worked!
它奏效了!
回答by u4608304
Under PyMongo 3.2, you can connect to MongoDB like this:
在 PyMongo 3.2 下,你可以像这样连接到 MongoDB:
from pymongo import MongoClient
c = MongoClient()
回答by serv-inc
In addition to https://stackoverflow.com/a/34766754/1587329, here's the API message(deprecated at 2.6.3, removed at 3.0):
除了https://stackoverflow.com/a/34766754/1587329 之外,这里是API 消息(在 2.6.3 弃用,在 3.0 删除):
Warning: DEPRECATED:
Connectionis deprecated. Please useMongoClientinstead.
警告:已弃用:
Connection已弃用。请MongoClient改用。

