致命的Python错误:init_fs_encoding:尝试启动uwsgi时,无法获取文件系统编码的Python编解码器

我试图在我的虚拟环境中启动我的 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

如果您需要更多详细信息,我会给它

谢谢

回答

我在浏览 Bing 而不是 Google 时找到了解决方案。

我看到你的 PYTHONHOME 设置为PYTHONHOME = '/home/env3/educ'. 尝试检查它是否真的存在。

的解决方案删除PYTHONHOME环境变量。对您来说,可以是这样,或者将该变量设置为另一个值。这适用于 Windows,并且肯定适用于 Linux。如果有人尝试此操作,请在此处发表评论!

一位 CPython 开发人员在这里确认了解决方案。:

这不是 Python 错误,这是在不需要 PYTHONHOME 和/或 PYTHONPATH 时设置它们的症状。在几乎所有情况下,您都不需要设置它们中的任何一个

在 PYTHONHOME 的情况下,设置.


以上是致命的Python错误:init_fs_encoding:尝试启动uwsgi时,无法获取文件系统编码的Python编解码器的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>