【问题标题】:WSGI Configuration failing on pythonanywhere due to module not being found由于找不到模块,pythonanywhere 上的 WSGI 配置失败
【发布时间】:2021-03-11 08:59:15
【问题描述】:

我目前正在尝试将我的 python/flask 应用程序部署到 pythonanywhere,但目前卡在 WSGI 配置步骤。这是我的代码:

import sys
#
## The "/home/azanbade" below specifies your home
## directory -- the rest should be the directory you uploaded your Flask
## code to underneath the home directory.  So if you just ran
## "git clone git@github.com/myusername/myproject.git"
## ...or uploaded files to the directory "myproject", then you should
## specify "/home/azanbade/myproject"
path = '/home/azanbade/path/to/Word-finder'
if path not in sys.path:
    sys.path.append(path)
#
from app import app as application  # noqa
#
# NB -- many Flask guides suggest you use a file called run.py; that's
# not necessary on PythonAnywhere.  And you should make sure your code
# does *not* invoke the flask development server with app.run(), as it
# will prevent your wsgi file from working.

在我尝试运行应用程序之前,一切看起来都很好。我继续收到此错误消息“ModuleNotFoundError: No module named 'app'

这是我的根目录和服务器(这是我的应用程序的主文件)的照片: Root Directory, Server

我的配置格式正确吗?

【问题讨论】:

    标签: python flask pythonanywhere


    【解决方案1】:

    您必须确保path 指向您的应用程序的正确路径。

    path = '/home/<your-username>/<path-to-your-app-folder>'
    

    【讨论】:

      猜你喜欢
      • 2019-03-25
      • 1970-01-01
      • 2016-01-02
      • 1970-01-01
      • 2020-08-19
      • 1970-01-01
      • 2018-02-02
      • 2021-03-21
      • 2019-12-26
      相关资源
      最近更新 更多