[英]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.