【问题标题】:uwsgi error - ModuleNotFoundError: No module named 'encodings'?uwsgi 错误 - ModuleNotFoundError:没有名为“编码”的模块?
【发布时间】:2026-01-07 19:30:02
【问题描述】:
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
setuid() to 1000
your processes number limit is 5568
your memory page size is 4096 bytes
detected max file descriptor number: 2560
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 127.0.0.1:8000 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:62444 (port auto-assigned) fd 3
Python version: 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53)  [Clang 6.0 (clang-600.0.57)]
!!! Python Home is not a directory: /Portenv !!!
Set PythonHome to /Portenv
Python path configuration:
  PYTHONHOME = '/Portenv'
  PYTHONPATH = (not set)
  program name = '/Portenv/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/Portenv/bin/python'
  sys.base_prefix = '/Portenv'
  sys.base_exec_prefix = '/Portenv'
  sys.executable = '/Portenv/bin/python'
  sys.prefix = '/Portenv'
  sys.exec_prefix = '/Portenv'
  sys.path = [
    '/Portenv/lib/python38.zip',
    '/Portenv/lib/python3.8',
    '/Portenv/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 0x00000001136aadc0 (most recent call first):
<no Python frame>

我尝试了其他一些堆栈溢出的答案,但我对 Django 很陌生,有些答案太模糊了最初,当我尝试初始化 uwsgi 时,我得到了这个错误。提前感谢任何人都可以提供的任何帮助

【问题讨论】:

  • 你的问题解决了吗?

标签: python django environment-variables virtualenv uwsgi


【解决方案1】:

此问题已在此线程中解决here。如果您以管理员身份运行 python setup 或已永久设置PYTHONHOME,则可能会导致错误。

撤消必要的操作,它应该可以解决您的问题。

【讨论】: