2016-02-23 97 views
1

我正在清理我的開發環境。我的代碼運行良好,但我想消除各種mongo驅動程序之間的任何衝突。但是現在,我從以下建立Flask-PyMongo和init_app()

<app.py> 

from database import mongo 

app = Flask(__name__) 
app.config.from_object('config') 
mongo.init_app(app) 

<database.py>

from flask.ext.pymongo import PyMongo 
mongo = PyMongo() 

產生的錯誤困惑提供了以下錯誤:

mongo.init_app(app) 
    File "/home/x/venv/local/lib/python2.7/site-packages/flask_pymongo/__init__.py", line 232, in init_app 
    cx = connection_cls(*args, **kwargs) 
    File "/home/x/venv/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 342, in __init__ 
    for k, v in keyword_opts.items()) 
    File "/home/x/venv/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 342, in <genexpr> 
    for k, v in keyword_opts.items()) 
    File "/home/x/venv/local/lib/python2.7/site-packages/pymongo/common.py", line 465, in validate 
    value = validator(option, value) 
    File "/home/x/venv/local/lib/python2.7/site-packages/pymongo/common.py", line 107, in raise_config_error 
    raise ConfigurationError("Unknown option %s" % (key,)) 
pymongo.errors.ConfigurationError: Unknown option auto_start_request 

在我requirements.txt我有:Flask-PyMongo==0.3.1

回答

1

您可能正在使用PyMongo<3.0版本上。

auto_start_request客戶端方法was removed在3.0版本和更改中添加到Flask-PyMongo==0.4.1

所以你應該升級Flask-PyMongo或降級PyMongo包。