gpt4 book ai didi

python - 尝试启动 uwsgi 时出现致命的 Python 错误 : init_fs_encoding: failed to get the Python codec of the filesystem encoding,

转载 作者:行者123 更新时间:2023-12-03 20:24:00 25 4
gpt4 key购买 nike

我试图在我的虚拟环境中启动我的 uwsgi 服务器,但是在我添加了 plugin python3 之后选项我每次都会收到此错误:

!!! Python Home is not a directory: /home/env3/educ !!!
Set PythonHome to /home/env3/educ
Python path configuration:
PYTHONHOME = '/home/env3/educ'
PYTHONPATH = (not set)
program name = '/home/env3/educ/bin/python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/home/env3/educ/bin/python'
sys.base_prefix = '/home/env3/educ'
sys.base_exec_prefix = '/home/env3/educ'
sys.executable = '/home/env3/educ/bin/python'
sys.prefix = '/home/env3/educ'
sys.exec_prefix = '/home/env3/educ'
sys.path = [
'/home/env3/educ/lib/python38.zip',
'/home/env3/educ/lib/python3.8',
'/home/env3/educ/lib/python3.8/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007efe89db8780 (most recent call first):
<no Python frame>
我还尝试使用 python3 -m venv env 创建新的虚拟环境并将项目文件移动到它,但仍然是同样的错误。
这是我的 uwsgi.ini 文件:
[uwsgi]

base = /home/env3/educ
projectname = educ

plugins = python3
master = true
virtualenv = /home/env3/%(projectname)
pythonpath = %(base)
env = DJANGO_SETTINGS_MODULE=%(projectname).settings.pro
module = %(projectname).wsgi:application
socket = /tmp/%(projectname).sock
chmod-socket = 666
我使用 Python 3.8.5
我正在尝试使用 Django + uWSGI + nginx + Postgresql。

最佳答案

我看到你的 PYTHONHOME 设置为 PYTHONHOME = '/home/env3/educ' .尝试检查它是否真的存在。
解决方案对我来说是 删除 PYTHONHOME环境变量 .
对您来说,可以是这样,或者将该变量设置为另一个值。
这适用于 Windows,并且肯定适用于 Linux。如果有人尝试这样做,请在此处发表评论!
一位 CPython 开发人员确认了解决方案 here. :

This is not a Python bug, this is a symptom of setting PYTHONHOME and/or PYTHONPATH when they’re not needed. In nearly all cases you don’t need to set either of them;

In the case of PYTHONHOME it’s almost always a mistake to set.

关于python - 尝试启动 uwsgi 时出现致命的 Python 错误 : init_fs_encoding: failed to get the Python codec of the filesystem encoding,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65184937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com