在空的CentOS上,我这样做(在教程https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-centos-7之后):
sudo yum install python-pip python-devel gcc nginx
sudo pip install virtualenv
mkdir ~/myproject
cd ~/myproject
virtualenv myprojectenv
source myprojectenv/bin/activate
pip install gunicorn flask
pip list
pip show flask
nano ~/myproject/myproject.py
python myproject.py
然后我得到:
Traceback (most recent call last):
File "myproject.py", line 1, in <module>
from flask import Flask
ModuleNotFoundError: No module named 'flask'
这可能是什么问题?
答案 0 :(得分:0)
您的及时更改了吗?像这样:
(myprojectenv)user @ host:〜/ myproject $
如果确实发生了变化,请运行python命令并查看其结果:
Python 3.6.2(v3.6.2:5fd33b5,Jul 8 2017,04:14:34)[win32 MSC v.1900 32位(Intel)] 输入“帮助”,“版权”,“信用”或“许可证”以获取更多信息。
CTRL + Z退出
同样,在运行脚本时,提示符应在前面包含(myprojectenv):
(myprojectenv)user @ host:〜/ myproject $ python myproject.py