1. 程式人生 > >uwsgi部署相關問題Fatal Python error: Py_Initialize: Unable to get the locale encoding

uwsgi部署相關問題Fatal Python error: Py_Initialize: Unable to get the locale encoding

directory config add bound int binary smp odi byte


uwsgi uwsgi.ini


啟動報錯


ini文件中切換用戶nginx後,因為權限問題,python虛擬環境變成了系統默認環境,缺少很多庫。


另外切換用戶啟動,可能沒有舊sock文件的權限,導致socket綁定失敗。應刪除舊socket。



(flask) [root@localhost flask]# uwsgi uwsgi.ini [uWSGI] getting INI configuration
from uwsgi.ini *** Starting uWSGI 2.0.17.1 (64bit) on [Sun Oct 21 03:50:21 2018] *** compiled with version:
4.8.5 20150623 (Red Hat 4.8.5-28) on 20 October 2018 12:54:58 os: Linux-3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 nodename: localhost.localdomain machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 2 current working directory: /var/flask detected binary path: /root/.local/share/virtualenvs/flask-VGoRTHto/bin/uwsgi setgid() to
995 setuid() to 997 chdir() to /var/flask/ *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 3802 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 UNIX address /var/flask/flask.sock fd 3 Python version: 3.4.9 (default, Aug 14 2018, 21:28:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] !!! Python Home is not a directory: /root/.local/share/virtualenvs/flask-VGoRTHto/ !!! Set PythonHome to /root/.local/share/virtualenvs/flask-VGoRTHto/ Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named encodings Current thread 0x00007f03d1f7e840 (most recent call first): 已放棄
    [uwsgi]
    # Http access port.
    # If this option comes into effect, we can visit our web site on http://[our IP]:[Port]
    # http=:5001

    # Uwsgis ip and port when it is loaded by Nginx
     socket=/var/flask/flask.sock

     chmod-socket=666
    uid = nginx
    gid = nginx
    # Point to the main directory of the Web Site
     chdir=/var/flask/

    # Setting up a virtual environment
     virtualenv=/root/.local/share/virtualenvs/flask-VGoRTHto/

    # Python startup file
     wsgi-file=app.py

    # The application variable of Python Flask Core Oject
     callable=app

    # The maximum numbers of Processes
     processes=1

    # The maximum numbers of Threads
     threads=2

虛擬環境下:

uwsgi -s /var/flask/flask.sock -w app:app

chmod 777 /var/flask.sock

啟動正常

uwsgi部署相關問題Fatal Python error: Py_Initialize: Unable to get the locale encoding