mod_wsgi:ImportError:部署Django应用程序的模块名为“ encodings”

时间:2019-03-12 15:29:31

标签: django apache mod-wsgi

我已经在这里找到以下错误的答案:mod_wsgi: ImportError: No module named 'encodings'

,由于未设置权限,似乎出现此错误。但对我来说,似乎所有权限设置都正确

这是我的文件结构:

home
└── user
    └── projects
        └── myapp
            ├── app
            │   ├── <All Code for Webapp including static dir>  
            ├── env (virtualenv)
            ├── manage.py
            ├── new
            │   ├── settings.py
            │   ├── urls.py
            │   └── wsgi.py
            └── requirements.txt

这是我的wsgi.conf文件,位于/etc/httpd/conf.d

Alias /static /home/user/projects/myapp/app/static
<Directory /home/user/projects/myapp/app/static>
    Require all granted
</Directory>

<Directory /home/user/projects/myapp/new>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess myapp python-path=/home/user/projects/myapp python-home=/home/user/projects/,myapp/env/lib/python3.6/site-packages user=<user>
WSGIProcessGroup myapp
WSGIScriptAlias / /home/user/projects/myapp/new/wsgi.py

现在,这是我在主目录中时的权限说明:

/ home

$ ls -l 
total 0
drwxrwxr-x. 5 <user> <group> 41 Mar  7 14:53 project

此权限在项目中是相同的,现在我获得myapp目录时的权限如下:

/ home / user / myapp

drwxrwxr-x. 7 <user> <group> 4096 Mar  7 13:18 app
drwxrwxr-x. 5 <user> <group>   56 Mar  7 14:42 env
-rwxrwxr-x. 1 <user> <group>  535 Mar  5 13:33 manage.py
drwxrwxr-x. 3 <user> <group>  110 Mar  7 14:27 new
-rw-rw-r--. 1 <user> <group>  869 Mar  7 14:42 requirements.txt

,而wsgi.py文件所在的权限(在新目录下)是:

/ home / user / myapp / new

-rw-rw-r--. 1 <user> <group>    0 Mar  5 13:33 debug.log
-rw-rw-r--. 1 <user> <group>    0 Mar  5 13:33 __init__.py
drwxrwxr-x. 2 <user> <group>  122 Mar  9 03:00 __pycache__
-rw-rw-r--. 1 <user> <group> 5442 Mar  8 10:17 settings.py
-rw-rw-r--. 1 <user> <group>  790 Mar  5 13:33 urls.py
-rw-rw-r--. 1 <user> <group>  383 Mar  5 13:33 wsgi.py

使用Apache运行mod_wsgi时,这些权限是否正确?

注意:上面的用户和组相同,是我的名字

1 个答案:

答案 0 :(得分:0)

检查用于配置mod_wsgi的python版本以及针对您的项目(virtual env)进行编译的python版本,当它们不同时出现此错误。