Нет модуля с именем 'encodings' с django3 - PullRequest
0 голосов
/ 23 марта 2020

уже запускает django программу в CentOS7 ежедневно.
Я хочу, чтобы перемещение centos7 было centos8.

Я пробую CentOS8. это настройка wsgi.

# dnf -y install python3-mod_wsgi
# vi /etc/httpd/conf.d/python3_wsgi.conf

это новый файл. запишите в новый файл.

WSGIScriptAlias /test_wsgi /var/www/html/test_wsgi.py
def application(environ, start_response):
    status = '200 OK'
    html = '<html>\n' \
           '<body>\n' \
           '<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">\n' \
           'WSGI TEST PAGE\n' \
           '</div>\n' \
           '</body>\n' \
           '</html>\n'.encode("utf-8")
    response_header = [('Content-type','text/html')]
    start_response(status,response_header)
    return [html]
# systemctl restart httpd

URL-адрес для chrome http://153.127.13.226/test_wsgi.
ОК! Оно работает! с wsgi!

, но создать django проект с venv тогда не работает один.

URL-адрес для chrome http://153.127.13.226/test_wsgi.
chrome - это ... о нет! 503!

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

каталог venv ... ... 1029 *

# python -c 'import sys; print(sys.prefix)'
  /home/op/venv

django проект ... ... 1032 *

# tree /var/www/html
/var/www/html
├ index.html
├ test_wsgi.py
└  testproject
    ├ manage.py
    └  testproject
        ├ __init__.py
        ├ asgi.py
        ├ settings.py
        ├ urls.py
        └  wsgi.py
WSGIDaemonProcess test_app python-path=/var/www/html/testproject python-home=/home/op/venv
WSGIProcessGroup test_app
WSGIScriptAlias /test_wsgi /var/www/html/testproject/testproject/wsgi.py
<Directory /var/www/html/testproject>
    Require all granted
</Directory>



журнал ошибок ... кажется бесконечным.

# tail -f /var/log/httpd/error_log
Current thread 0x00007f65e9c55900 (most recent call first):
[Mon Mar 23 21:13:57.702501 2020] [core:notice] [pid 26583:tid 140075690449152] AH00052: child pid 7780 exit signal Aborted (6)
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Я уже ищу стек по потоку, но пока не решаю.
Я думаю, что это немного больше, но у меня есть стек через поток.

1 Ответ

0 голосов
/ 27 марта 2020

OK! Я был решен!
, но я много раз сбрасывал ОС.
Ошибка не воспроизводилась.

Возможно, причина - "SE Linux"
Сейчас Я не знаю, в чем причина, поэтому я представлю окончательное содержимое настройки и URL, который суммирует процесс (извините, японский язык)

django имя проекта: mysite

LoadModule wsgi_module /var/www/html/venv/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
WSGIScriptAlias / /var/www/html/mysite/mysite/wsgi.py
WSGIDaemonProcess wsgi_app python-home=/var/www/html/venv python-path=/var/www/html/mysite
WSGIProcessGroup wsgi_app
WSGISocketPrefix /var/run/wsgi

процесс: https://qiita.com/YoshitakaOkada/items/a75f664846c8c8bbb1e1#% E3% 83% 91% E3% 83% BC% E3% 83% 9F% E3% 83% 83% E3% 82% B7% E3% 83% A7% E3% 83% B3% E3% 83% 81% E3% 82% A7% E3% 83% 83% E3% 82% AF

...