@Matthew06

Как исправить проблему ModuleNotFoundError: No module named 'encodings'?

Недавно на рабочей машине запустил свое приложение с помощью Apache и решил перенести его на сервер. На сервере Debian apache, почему-то, показывает следующую ошибку: ModuleNotFoundError: No module named 'encodings'. У себя я уже сталкивался с с такой ошибкой и она заключалась в том, что я неправильно указывал путь до venv (python-home). В данном случае я (как мне кажется) указал пути правильно, но все равно возникает эта ошибка. Более того - когда я указываю, казалось бы, верный python-home - он меняет его на другой (можно сравнить с error.log).

000-default.conf
<VirtualHost *:8080>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        alias /static /var/www/html/prohect_iem/static
        alias /res_files /var/www/html/prohect_iem/res_files
        <Directory /var/www/html/prohect_iem/res_files>
                Require all granted
        </Directory>
        <Directory /var/www/html/prohect_iem/static>
                Require all granted
        </Directory>

        #WSGIPythonHome /usr/lib/python3.11
        #WSGIPythonPath /var/www/html
        <Directory /var/www/html/>
        AllowOverride All
        </Directory>
        <Directory /var/www/html/prohect_iem/base/>
                Order allow,deny
                Allow from all
                <Files wsgi.py>
                Require all granted
                </Files>
        </Directory>
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        WSGIDaemonProcess prohect_iem  python-path=/var/www/html/prohect_iem python-home=/var/www/html/prohect_iem/env
        WSGIProcessGroup prohect_iem
        WSGIScriptAlias / /var/www/html/prohect_iem/base/wsgi.py
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>


error.log
Current thread 0x00007f5c02e8e780 (most recent call first):
  <no Python frame>
Python path configuration:
  PYTHONHOME = '/usr/lib/python3.11'
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/usr/lib/python3.11/lib/python3.11'
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/usr/lib/python3.11'
  sys.base_exec_prefix = '/usr/lib/python3.11'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/usr/lib/python3.11'
  sys.exec_prefix = '/usr/lib/python3.11'
  sys.path = [
    '/usr/lib/python3.11/lib/python311.zip',
    '/usr/lib/python3.11/lib/python3.11',
    '/usr/lib/python3.11/lib/python3.11/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'
  • Вопрос задан
  • 62 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы