ImportError:亚马逊lightail上没有名为“ flask”的模块

我正在尝试在我的lightail实例上设置flask,但是遇到了问题。在我的apache2 error.log中,我得到了错误。

from flask import flask
[Wed Nov 06 15:10:44.931654 2019] [wsgi:error] [pid 27144:tid 139804352530176] [client 72.133.209.13:63459] ImportError: No module named 'flask'

我用sudo apt-get install python-minimal安装了python 2.7。我已经安装了apache2和libapache2-mod-wsgi。我还通过pip install flask安装了flask,并且在我的项目目录中设置了虚拟环境,并在虚拟环境中通过pip安装了flask。我试过只在虚拟环境的内部和外部安装flask的情况下运行它,但均无效。

我的项目位于home / ubuntu / Exampleflask / Exampleflask中。我那里有3个文件。空白的 init .py文件。然后我有my_flask_app.py:

from flask import flask
app = flask(__name__)
@app.route("/")
def hello():
    return "Hello world!"
if __name__ == "__main__":
    app.run()

然后我有my_flask_app.wsgi:

#!/usr/bin/env python

import logging
import sys
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,'/home/ubuntu/Exampleflask/Exampleflask/')
from my_flask_app import app as application
application.secret_key = 'super_secret_key'

etc / apache2 / sites-enabled / Exampleflask.conf中的配置文件如下:

<VirtualHost *:80>
     # Add machine's IP address (use ifconfig command)
     ServerName 18.217.87.146
     # Give an alias to to start your website url with
     WSGIScriptAlias /testflask /home/ubuntu/Exampleflask/Exampleflask/my_flask$
     <Directory /home/ubuntu/Exampleflask/Exampleflask/>
                # set permissions as per apache2.conf file
            Options FollowSymLinks
            AllowOverride None
            Require all granted
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/error.log
     LogLevel warn
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

我无法弄清楚为什么我收到了名为flask import错误的no模块。你知道我如何让它运行吗?

非常感谢你, 迈克尔

wearekill000 回答:ImportError:亚马逊lightail上没有名为“ flask”的模块

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3150940.html

大家都在问