python+gunicorn+nginx部署遇到的坑

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

2018-6-13  [11923] [INFO] Starting gunicorn 18.0
2018-6-13 [11923] [INFO] Listening at: http://127.0.0.1:8000 (11923)
2018-6-13  [11923] [INFO] Using worker: sync
2013-6-13  [11926] [INFO] Booting worker with pid: 11926

猜你喜欢

转载自blog.csdn.net/qq_15256443/article/details/80693460
今日推荐