简体   繁体   English

Apache2 WSGI Flask 服务器使用错误的 Python 解释器

[英]Apache2 WSGI Flask server using wrong Python Interpreter

When I run my apache2 Flask server on my VPS, I get this error当我在我的 VPS 上运行我的 apache2 Flask 服务器时,我收到此错误在此处输入图像描述

After checking the error.log file of apache, I found these errors:检查apache的error.log文件后,我发现了这些错误: 在此处输入图像描述

As you can see, there is a SyntaxError on the first f-string of the code and of course there is a very large amount of ImportError 's.如您所见,代码的第一个 f 字符串上有一个SyntaxError ,当然还有大量的ImportError I am convinced that the SyntaxError is caused by the Python Interpreter mod_wsgi is using.我确信SyntaxError是由正在使用的 Python 解释器 mod_wsgi 引起的。 This is how the app.wsgi file looks like: app.wsgi文件如下所示:

在此处输入图像描述

(The reason I used the project's path is because of the Virtual Enviroment I'm using is inside the project:) (我使用项目路径的原因是因为我使用的虚拟环境在项目内部:)

在此处输入图像描述

The 000-default.conf file: 000-default.conf文件: 在此处输入图像描述

I have 3 Python versions installed on the VPS;我在 VPS 上安装了 3 个 Python 版本; Python 3.8, Python 3 and Python 2.7 Python 3.8、Python 3 和 Python 2.7

Every project has it's own venv (Virtual Enviroment) installed, as you can see from the 3rd image I provided, the Flask app doesn't use the Python that is in the /usr/ folder.每个项目都安装了自己的 venv(虚拟环境),从我提供的第三张图片可以看出,Flask 应用程序不使用/usr/文件夹中的 Python。 I don't know what I am doing wrong, I would appreciate any type of help我不知道我做错了什么,我将不胜感激任何类型的帮助

I finally fixed it.我终于修好了。 You can check this GitHub issue.您可以查看GitHub 问题。

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

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