简体   繁体   English

烧瓶导入错误

[英]Flask Import Error

I'm running the following code in a file called init .py that works.我正在一个名为init .py 的文件中运行以下代码,该文件有效。

from flask import Flask, render_template, request, url_for, redirect, Response


app = Flask(__name__)

@app.route('/')
def homepage():
    return render_template('index4.html')

if __name__ == "__main__":
app.run(host='0.0.0.0', port=80, debug=True, threaded=True)

When I try to import a file (from "file" import "function") or a python (import "package") it causes a 500 error.当我尝试导入文件(从“文件”导入“函数”)或 python(导入“包”)时,它会导致 500 错误。 The code that causes the error is below.导致错误的代码如下。

from flask import Flask, render_template, request, url_for, redirect, Response
from file import function

app = Flask(__name__)

 @app.route('/')
    def homepage():
        return render_template('index4.html')

    if __name__ == "__main__":
    app.run(host='0.0.0.0', port=80, debug=True, threaded=True)

Any help would really be appreciated.任何帮助将不胜感激。

Turns out the issue was related to the permissions on the directory that contained the site packages.原来问题与包含站点包的目录的权限有关。

By changing the permissions on /usr/local/lib/python2.7/dist-packages and adding WSGIApplicationGroup %{GLOBAL} to the FlaskApp.conf file I was able to resolve the problem.通过更改 /usr/local/lib/python2.7/dist-packages 的权限并将 WSGIApplicationGroup %{GLOBAL} 添加到 FlaskApp.conf 文件,我能够解决问题。

Thanks @mmenschig for the help.感谢@mmenschig 的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM