您的 WSGIPath 引用了一个不存在的文件 [英] Your WSGIPath refers to a file that does not exist

查看:22
本文介绍了您的 WSGIPath 引用了一个不存在的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的 Flask 应用程序上传到 AWS,但是我在这样做时收到错误:

I'm trying to upload my Flask application to AWS however I receive an error on doing so:

您的 WSGIPath 引用了一个不存在的文件.

Your WSGIPath refers to a file that does not exist.

在网上做了一些挖掘后,我发现在 .ebextensions 文件夹中,我应该指定路径.没有 .ebextensions 文件夹,所以我创建了一个并将以下代码添加到名为 settings.config 的文件中:

After doing some digging online I found that in the .ebextensions folder, I should specify the path. There was not a .ebextensions folder so I created one and added the following code to a file named settings.config:

option_settings:
  "aws:elasticbeanstalk:container:python":
    WSGIPath: project/application.py

WSGIPath 是 application.py 文件的正确路径,所以我不确定是什么引发了这个错误.我是否正确更改了 WSGIPath,是否有更好的方法,或者是否存在其他导致这种情况发生的问题?谢谢.

the WSGIPath is the correct path to the application.py file so I'm not sure what raises this error. Am I changing the WSGIPath right, is there a better way or is there an issue with something else which causes this to happen? Thanks.

推荐答案

在 AWS 上部署 Flask 可能会出现很多配置问题.我遇到了与您类似的问题,所以我至少可以向您展示我为解决 WSGI 错误所做的工作.

There's a lot of configuration issues that can arise with Flask deployed on AWS. I was running into a similar issue as you, so I can at least show you what I did to resolve the WSGI error.

首先,显然您可以在没有 .ebextensions 文件夹的情况下执行此操作(请参阅此帖子 此处.并查看 davetw12 的答案.但是,请注意,虽然这有效,但根据以下一些评论,我并不完全确定 davetw12 关于 .ebextensions 的结论是否正确).相反,(在终端中),我导航到与我的 .elasticbeanstalk 目录处于同一级别的我的项目,并使用命令 eb config.这将打开一个选项列表,您可以设置它来配置您的 beanstalk 应用程序.向下浏览选项,直到找到 WSGI 路径.我注意到你已经将你的设置为 project/application.py,但是,这不应该包括文件夹引用,只包括 application.py.这是它在我的 Mac 终端上的外观(WSGI 路径在底部附近).

First, apparently you can do this without the .ebextensions folder (see this post here. and look at davetw12's answer. However, be aware that while this works, I'm not entirely sure that davetw12's conclusion about .ebextensions is correct, based on some of the comments below). Instead, (in the Terminal), I navigated to my project at the same level as my .elasticbeanstalk directory and used the command eb config. This will open up a list of options you can set to configure your beanstalk application. Go down through the options until you find the WSGI path. I notice you have yours set to project/application.py, however, this should not include the folder reference, just application.py. Here is how it looks on my Mac in the terminal (WSGI path is near the bottom).

请注意,一旦获得该设置,EB 可能会重新部署.没关系.让它.

Note that once you get that set, EB will probably redeploy. That's fine. Let it.

一旦你设置好了,进入你的 application.py 文件并确保你调用你的应用程序 application.例如,我的看起来像这样:

Once you get that set, go into your application.py file and make sure you call your app application. For example, mine looks like this:

from flask import Flask
from flask import render_template
application = Flask(__name__)

@application.route('/')
@application.route('/index')
def index():
    return render_template('index.html',
                           title='Home')

这消除了 WSGI 路径错误 - 尽管我仍然需要解决一些其他问题 :-) 但这是一组不同的问题.

This took away the WSGI path error - although I still had to fix some other issues following this :-) But that is a different set of questions.

这篇关于您的 WSGIPath 引用了一个不存在的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆