简体   繁体   English

Django + mod_wsgi 致命的 Python 错误:Py_Initialize:没有名为 Encodings 的模块

[英]Django + mod_wsgi Fatal Python Error: Py_Initialize: No module named Encodings

I am attempting to get a website to load within a web browser using Django + mod_wsgi and apache.我正在尝试使用 Django + mod_wsgi 和 apache 将网站加载到 Web 浏览器中。 I have exactly the same problem as in This Question Here , but the solution found there does not work in my case.我有与This Question Here完全相同的问题,但在那里找到的解决方案在我的情况下不起作用。

Here is my httpd-vhosts.conf setup:这是我的 httpd-vhosts.conf 设置:

WSGIDaemonProcess binshellpress.com python-home=/usr/local/docs/binshellpress-production/virtpy/ python-path=/usr/local/docs/binshellpress-production/virtpy/lib/python3.6/
WSGIProcessGroup binshellpress.com
WSGIApplicationGroup %{GLOBAL}

<VirtualHost *:80>
  ServerAdmin webmaster@binshellpress.com
  DocumentRoot "/usr/local/docs/binshellpress-production/root"
  ServerName binshellpress.com
  ServerAlias www.binshellpress.com
  ErrorLog "/var/log/httpd/bsp-error_log"
  CustomLog "/var/log/httpd/bsp-access_log" common

  Alias /robots.txt /usr/local/docs/binshellpress-production/static/robots.txt
  Alias /favicon.ico /usr/local/docs/binshellpress-production/static/favicon.ico

  Alias /media/ /usr/local/docs/binshellpress-production/media
  Alias /static/ /usr/local/docs/binshellpress-production/static

  <Directory /usr/local/docs/binshellpress-production/static>
    Require all granted
  </Directory>

  <Directory /usr/local/docs/binshellpress-production/media>
    Require all granted
  </Directory>

  WSGIScriptAlias / /usr/local/docs/binshellpress-production/binshellpress/wsgi.py process-group=binshellpress.com

  <Directory /usr/local/docs/binshellpress-production/binshellpress>
    <Files wsgi.py>
      Require all granted
    </Files>
  </Directory>
</Virtualhost>

I have a virtual environment set up at /usr/local/docs/binshellpress-production/virtpy .我在/usr/local/docs/binshellpress-production/virtpy设置了一个虚拟环境。 I have rebuilt mod_wsgi to explicitly use that virtual environment.我重建了 mod_wsgi 以明确使用该虚拟环境。 I have performed the permissions modifications as described in the answer to This Question我已按照此问题的答案中所述执行了权限修改

No change.没变。

I am desperate.生无可恋。 I have been searching up and down.我一直在上下寻找。 I can't figure out what to do.我不知道该怎么办。 Please, help me.请帮我。 I beg you.我求求你。

Thank you, for anything, thank, just please, help me, thank you.谢谢,任何事情,谢谢,请帮帮我,谢谢。

First off, check the value of python-home is correct by running command line Python you want to use and do:首先,通过运行您要使用的命令行 Python 来检查python-home的值是否正确,然后执行以下操作:

import sys
sys.prefix

It should be the same value.它应该是相同的值。

Also be aware that:另请注意:

python-path=/usr/local/docs/binshellpress-production/virtpy/lib/python3.6/

shouldn't be needed and I can't see why you would add that.不应该需要,我不明白你为什么要添加它。

Next, run the check in:接下来,运行检入:

What libraries and locations is mod_wsgi linked against? mod_wsgi 链接到哪些库和位置?

If your mod_wsgi binary is definitely compiled against the correct Python version, the only other issue it could be is that it is a non standard Python installation and not a system Python.如果您的 mod_wsgi 二进制文件肯定是针对正确的 Python 版本编译的,那么唯一的其他问题可能是它是非标准 Python 安装而不是系统 Python。 If this is the case and it isn't linked correctly, it may be finding the system Python shared library instead of that for your separate Python installation.如果是这种情况并且它没有正确链接,它可能会找到系统 Python 共享库,而不是您单独的 Python 安装。

Again from the command line for Python from the virtual environment, try:再次从虚拟环境中的 Python 命令行,尝试:

import sys
sys.real_prefix

What do you get for that?你能得到什么?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ubuntu,Apache2,Django)致命Python错误:Py_Initialize:无法获取区域设置编码ImportError:没有名为“ encodings”的模块 - Ubuntu , Apache2 , Django ) Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' gcc 6.3 --&gt; 致命 Python 错误:Py_Initialize:无法获取语言环境编码 ModuleNotFoundError:没有名为“编码”的模块 - gcc 6.3 --> Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings' 致命的 Python 错误:Py_Initialize:无法加载文件系统编解码器。 导入错误:没有名为“编码”的模块 - Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' mod_wsgi:ImportError:没有名为&#39;encodings&#39;的模块 - mod_wsgi: ImportError: No module named 'encodings' Py_Initialize引发ModuleNotFoundError:没有名为“编码”的模块 - Py_Initialize throws ModuleNotFoundError: No module named 'encodings' Django Python mod_wsgi:ImportError:没有名为“ django”的模块 - Django Python mod_wsgi: ImportError: No module named 'django' Django/mod_wsgi/Apache - mod_wsgi 没有使用为它编译的 Python 版本 - “ModuleNotFoundError: No module named 'math'” - Django/mod_wsgi/Apache - mod_wsgi is not using the Python version it was compiled for - “ModuleNotFoundError: No module named 'math' ” mod_wsgi:无法统计Python主目录和ImportError:没有名为“ encodings”的模块 - mod_wsgi: Unable to stat Python home and ImportError: No module named 'encodings' 致命的Python错误:Py_Initialize() - Fatal Python error: Py_Initialize() 在Anaconda内部的Python上使用mod_wsgi配置Django时出错:“ImportError:没有名为django.core.wsgi的模块” - Error while configuring Django with mod_wsgi on Python inside Anaconda: “ImportError: No module named django.core.wsgi”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM