在Ubuntu 16.04服务器中部署Flask应用程序时出错

时间:2019-02-23 04:47:06

标签: flask apache2 ubuntu-16.04 python-3.6 web3

我正在尝试在Ubuntu 16.04中部署Flask应用程序

这给了我以下错误,我正在尝试使用python3.6

[Sat Feb 23 04:18:07.988418 2019] [wsgi:error] [pid 16429:tid 139859511379712] 3.5.2 (default, Nov 12 2018, 13:43:14) 
[Sat Feb 23 04:18:07.988459 2019] [wsgi:error] [pid 16429:tid 139859511379712] [GCC 5.4.0 20160609]
[Sat Feb 23 04:18:07.988466 2019] [wsgi:error] [pid 16429:tid 139859511379712] 
[Sat Feb 23 04:18:07.988488 2019] [wsgi:error] [pid 16429:tid 139859511379712] ['/var/www/EthApp/', '/var/www/EthApp/', '/var/www/EthApp/', '/var/www/EthApp/', '/var/www/EthApp/', '/var/www/EthApp/', '/var/www/EthApp/', '/var/www/EthApp/', '/var/www/EthApp/', '/var/www/EthApp/', '/var/www/EthApp/', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
[Sat Feb 23 04:18:07.989346 2019] [wsgi:error] [pid 16429:tid 139859511379712] [client 116.73.204.144:61239] mod_wsgi (pid=16429): Target WSGI script '/var/www/EthApp/ethapp.wsgi' cannot be loaded as Python module.
[Sat Feb 23 04:18:07.989391 2019] [wsgi:error] [pid 16429:tid 139859511379712] [client 116.73.204.144:61239] mod_wsgi (pid=16429): Exception occurred processing WSGI script '/var/www/EthApp/ethapp.wsgi'.
[Sat Feb 23 04:18:07.989519 2019] [wsgi:error] [pid 16429:tid 139859511379712] [client 116.73.204.144:61239] Traceback (most recent call last):
[Sat Feb 23 04:18:07.989553 2019] [wsgi:error] [pid 16429:tid 139859511379712] [client 116.73.204.144:61239]   File "/var/www/EthApp/ethapp.wsgi", line 9, in <module>
[Sat Feb 23 04:18:07.989575 2019] [wsgi:error] [pid 16429:tid 139859511379712] [client 116.73.204.144:61239]     from EthApp import app as application
[Sat Feb 23 04:18:07.989601 2019] [wsgi:error] [pid 16429:tid 139859511379712] [client 116.73.204.144:61239]   File "/var/www/EthApp/EthApp/__init__.py", line 1, in <module>
[Sat Feb 23 04:18:07.989620 2019] [wsgi:error] [pid 16429:tid 139859511379712] [client 116.73.204.144:61239]     from flask import Flask,render_template
[Sat Feb 23 04:18:07.989660 2019] [wsgi:error] [pid 16429:tid 139859511379712] [client 116.73.204.144:61239] ImportError: No module named 'flask'

我的项目结构是:

EthApp
|_EthApp__
|        |_static
|        |_templates
|        |_ __init__py
|_ethapp.wsgi

__ init__.py是:

from flask import Flask,render_template
app = Flask(__name__)
@app.route("/")
def hello():
    return render_template("main.html")
if __name__ == "__main__":
    app.run()

ethapp.wsgi是:

#!/usr/bin/python3.6
import sys
import logging
logging.basicConfig(stream=sys.stderr)
print(sys.version)
print(sys.path)
sys.path.insert(0,"/var/www/EthApp/")

from EthApp import app as application
application.secret_key = 'add key'

当我尝试使用以下命令调试wsgi文件时:

$python3.6 -i /var/www/EthApp/ethapp.wsgi
  

3.6.7(默认值,2018年10月25日,09:16:13)[GCC 5.4.0 20160609] ['/ var / www / EthApp','/usr/lib/python36.zip', '/usr/lib/python3.6',   '/usr/lib/python3.6/lib-dynload',   '/usr/local/lib/python3.6/dist-packages',   '/ usr / lib / python3 / dist-packages']

0 个答案:

没有答案