文章内容

2018/5/25 17:30:45,作 者: 黄兵

gunicorn no module named flask

最近在Ubuntu上面部署Flask应用程序,报如下错误:

File "/var/Material-Prices/app/__init__.py", line 2, in <module>

    from flask import Flask, render_template

ImportError: No module named flask

使用的是gunicorn,这个一看是缺少falsk模块,使用pip install flask,但是运行:gunicorn manage:manager 依然还是报相同错误。

产生原因:
由于某种原因,gunicorn将环境加载到虚拟环境之外。 我通过在虚拟环境之外卸载包gunicorn来解决问题。

解决方案:
首先退出虚拟环境,卸载gunicorn
(env) $ deactivate
$ sudo pip uninstall gunicorn
再次进入虚拟环境:
$ source env/bin/activate
(env) $ pip install gunicorn
(env) $ gunicorn server:app

2013-10-19 20:40:56 [11923] [INFO] Starting gunicorn 18.0
2013-10-19 20:40:56 [11923] [INFO] Listening at: http://127.0.0.1:8000 (11923)
2013-10-19 20:40:56 [11923] [INFO] Using worker: sync
2013-10-19 20:40:56 [11926] [INFO] Booting worker with pid: 11926


参考资料:Gunicorn with Flask using wrong Python


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - gunicorn no module named flask

分享到:

发表评论

评论列表