Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'
查了好多资料都查不出问题 有人知道怎么弄吗
1
Yourshell 2018-03-12 22:15:20 +08:00
|
2
chaunceywe 2018-03-12 23:32:59 +08:00 via Android
sudo apt-get install python3-dev -y
|
3
luckyqiang OP @chaunceywe 试了还是不行 感觉是 py2 和 py3 的环境乱了 我 django 用的是 py3 把服务器 ubuntu 里也默认改为 py3 了 不知道哪里出了问题
|
4
chaunceywe 2018-03-13 09:30:21 +08:00 via Android
@luckyqiang 只是没安装 python 依赖的问题,用 python 几安装几的
|
5
luckyqiang OP @chaunceywe python3-dev is already the newest version (3.5.1-3). 应该安装了吧
|
6
luckyqiang OP @chaunceywe (mysite_env) ubuntu@VM-0-8-ubuntu:~/myblog$ uwsgi --ini uwsgi.ini
[uWSGI] getting INI configuration from uwsgi.ini *** Starting uWSGI 2.0.17 (64bit) on [Tue Mar 13 09:56:19 2018] *** compiled with version: 5.4.0 20160609 on 12 March 2018 08:17:28 os: Linux-4.4.0-91-generic #114-Ubuntu SMP Tue Aug 8 11:56:56 UTC 2017 nodename: VM-0-8-ubuntu machine: x86_64 clock source: unix detected number of CPU cores: 1 current working directory: /home/ubuntu/myblog detected binary path: /home/ubuntu/.local/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! chdir() to /home/ubuntu/myblog/mysite_env/mysite your processes number limit is 3306 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uwsgi socket 0 bound to TCP address :8001 fd 3 Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] Set PythonHome to /home/ubuntu/myblog/mysite_env Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' Current thread 0x00007fd0c8473700 (most recent call first): Aborted (core dumped) 运行就是报这样的错误 |
7
luckyqiang OP @Yourshell (mysite_env) ubuntu@VM-0-8-ubuntu:~/myblog$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 我的 python 应该没有问题 |
8
xvx 2018-03-13 10:19:02 +08:00 via iPhone
这是我用 Django/Flask 开发的个人博客,uwsgi+nginx 我是这么部署的,没有出现你这种报错,你可以将虚拟环境卸载了重新创建一个,按照我的方法试试?
我的 Github 里面还有相应的配置文件,都开源出来了,可以参考下。 http://www.vua.sh/#7974a888-0a55-488b-b48b-23dcdd6826ac |
9
Kirikora 2018-03-13 10:23:05 +08:00 via Android
@luckyqiang uwsgi 也装在虚拟环境里,然后调用虚拟环境里的 uwsgi 试试?
|
10
Kirikora 2018-03-13 10:26:13 +08:00 via Android
|
11
luckyqiang OP @xvx 我是把本地的虚拟环境也打包上去了 估计就是那个问题 本地是 python3.6 服务器好像是 3.5
|
12
xvx 2018-03-14 08:47:27 +08:00
@luckyqiang 不建议这么干。一般虚拟环境都是在服务器上面部署时创建的,本地环境跟服务器环境有些版本、依赖不一致,你最好是在服务器上面新建一个虚拟环境。
|