当我在Flask应用程序上执行“foreman start”时,我遇到了这个问题。
(venv)Macbook-err:Example ld$ foreman start
14:01:50 web.1 | started with pid 1441
14:01:50 web.1 | Traceback (most recent call last):
14:01:50 web.1 | File "app.py", line 26, in <module>
14:01:50 web.1 | connect('mydata', host=os.environ.get('MONGOLAB_URI'))
14:01:50 web.1 | File "/Users/ld/Dropbox/Semester4/Example/venv/lib/python2.7/site-packages/mongoengine/connection.py", line 160, in connect
14:01:50 web.1 | register_connection(alias, db, **kwargs)
14:01:50 web.1 | File "/Users/ld/Dropbox/Semester4/Example/venv/lib/python2.7/site-packages/mongoengine/connection.py", line 54, in register_connection
14:01:50 web.1 | if "://" in host:
14:01:50 web.1 | TypeError: argument of type 'NoneType' is not iterable
14:01:50 web.1 | exited with code 1
14:01:50 system | sending SIGTERM to all processes
SIGTERM received
在我的app.py(第26行)中我有:
connect('mydata', host=os.environ.get('MONGOLAB_URI'))
app.logger.debug("Connecting to MongoLabs")
我做了heroku config | grep MONGOLAB_URI > .env
所以.env文件应该是合法的。
有什么建议吗?
答案 0 :(得分:0)
heroku config | grep MONGOLAB_URI > .env
输出格式为MONGOLAB_URI: mong...
,应更改为MONGOLAB_URI=mongo....
答案 1 :(得分:0)
如果您使用带有两个箭头的heroku config | grep MONGOLAB_URI >> .env
代替它会有帮助吗?要附加输出?