cygwin python installation: "Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding"

cygwin python installation: "Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding"

我正在尝试设置新的 cygwin 安装并通过 cygwin 安装 python。我这样做了,并且设置完成了,但是当我尝试 运行 python3.8 时,我得到了一个致命的 python 错误:

$ python3.8
Python path configuration:
  PYTHONHOME = 'C:\Users\cmhac\AppData\Local\Programs\Python\Python38'
  PYTHONPATH = 'C:\Users\cmhac\AppData\Local\Programs\Python\Python38'
  program name = 'python3.8'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3.8.exe'
  sys.base_prefix = 'C'
  sys.base_exec_prefix = '\Users\cmhac\AppData\Local\Programs\Python\Python38'
  sys.executable = '/usr/bin/python3.8.exe'
  sys.prefix = 'C'
  sys.exec_prefix = '\Users\cmhac\AppData\Local\Programs\Python\Python38'
  sys.path = [
    'C',
    '\Users\cmhac\AppData\Local\Programs\Python\Python38',
    'C/lib/python38.zip',
    'C/lib/python3.8',
    '\Users\cmhac\AppData\Local\Programs\Python\Python38/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 0x0000000800000010 (most recent call first):
<no Python frame>

我该如何开始解决这个问题? python38.exe 文件在那里,一切似乎都很好。从未在任何其他 python 安装中出现此错误。

我看到了这个确切的错误: 致命 Python 错误:init_fs_encoding:无法获取文件系统编码的 Python 编解码器 Python 运行时状态:核心已初始化 ModuleNotFoundError:没有名为 'encodings'

的模块

如果将这两个环境变量设置为 nil,问题应该会消失: 设置蟒蛇之家= 设置 PYTHONPATH=

转到项目下的 wsgi.py 文件并执行类似以下操作:

import os
import sys

from django.core.wsgi import get_wsgi_application

sys.path.append('path/to/yourprojectenv/lib/python3.8/site-packages')

重新启动服务器并重试。