gpt4 book ai didi

python-3.x - 如何修复Python3.7.1中的 "No module named '编码?

转载 作者:行者123 更新时间:2023-12-05 08:11:25 24 4
gpt4 key购买 nike

我尝试为 myproject(mywords_dict) 启动 uwsgi:

uwsgi --http :8000  -H /root/mywords_dict/env --chdir mywords_dict -w mywords_dict.wsgi

但收到以下错误:

Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

我很困惑,如果我进入虚拟环境后运行uwsgi,它可以很好地工作。'mywords_dict'的Python版本是3.7.1。我检查了 mywords_dic/env 中是否有编码包。我可以从那里成功运行 python。有人可以帮忙吗?

*** Starting uWSGI 2.0.18 (64bit) on [Fri Aug 30 00:15:16 2019] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-36) on 29 August
2019 13:49:55
os: Linux-3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018
nodename: VM_0_17_centos
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /root
detected binary path: /root/.pyenv/versions/3.7.1/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to mywords_dict
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3882
your memory page size is 4096 bytes
detected max file descriptor number: 100001
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
spawned uWSGI http 1 (pid: 22645)
uwsgi socket 0 bound to TCP address 127.0.0.1:42301 (port auto-assigned) fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.7.1 (default, Nov 11 2018, 01:35:46) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Set PythonHome to /root/mywords_dict/env
**Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'**

最佳答案

这是因为错误的python虚拟环境路径。它在 home 变量下的 .ini 文件中定义。

您需要做的是分配给这个指向您的 venv 的 root 的变量路径。所以如果你的venv路径是/home/user/project/venv,只需将这个路径赋给home变量即可。确保在 venv 路径中包含尾部 /(斜线)(因为它稍后连接到 /bin/python 并且您将以双斜杠结尾。

然后保存你的.ini文件并尝试再次启动uWSGI。

关于python-3.x - 如何修复Python3.7.1中的 "No module named '编码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57714418/

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