[英]Apache virtualenv and mod_wsgi : ImportError : No module named 'django'
I'm having issues running django and apache2/mod_wsgi. 我在运行django和apache2 / mod_wsgi时遇到问题。 This is my current setup: 这是我当前的设置:
Ubuntu: 16.0
Apache: 2.4.18
Python: 3.5
Django: 1.10
I have installed a virtualenv inside my django project for user 'carma'. 我在django项目中为用户'carma'安装了virtualenv。 Structure is: 结构是:
/home/carma/mycarma
|- manage.py
static
mycarma
|__init__.py
|settings.py
|urls.py
|wsgi.py
mycarmanev
bin
include
lib
This is the content of /etc/apache2/sites-available/000-default.conf 这是/etc/apache2/sites-available/000-default.conf的内容
<VirtualHost *:80>
Alias /static /home/carma/mycarma/static
<Directory /home/carma/mycarma/static>
Require all granted
</Directory>
<Directory /home/carma/mycarma/mycarma>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess mycarma python-path=/home/carma/mycarma/ python-home=/home/carma/mycarma/mycarmavirtuale$
WSGIProcessGroup mycarma
WSGIScriptAlias / /home/carma/mycarma/mycarma/wsgi.py
This is the content of wsgi.py 这是wsgi.py的内容
import os,sys
from django.core.wsgi import get_wsgi_application
DJANGO_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
sys.path.append(DJANGO_PATH)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mycarma.settings")
application = get_wsgi_application()
And I have already given permissions: 而且我已经授予权限:
sudo chown -R www-data:www-data /home/carma/mycarma/mycarmaenv
sudo chown -R www-data:www-data /home/carma/mycarma
The problem comes when I try to access the url of my server, checking the apache log this is the issue: 当我尝试访问服务器的URL,检查apache日志时,就会出现问题:
[wsgi:error] [pid 25183] mod_wsgi (pid=25183): Target WSGI script '/home/carma/mycarma/mycarma/wsgi.py' cannot be loaded as Python module.
[wsgi:error] [pid 25183] mod_wsgi (pid=25183): Exception occurred processing WSGI script '/home/carma/mycarma/mycarma/wsgi.py'.
[wsgi:error] [pid 25183] Traceback (most recent call last):
[wsgi:error] [pid 25183] File "/home/carma/mycarma/mycarma/wsgi.py", line 12, in <module>
[wsgi:error] [pid 25183] from django.core.wsgi import get_wsgi_application
[wsgi:error] [pid 25183] ImportError: No module named 'django'
I have read all the possible discussions here and outside, found also this thread which expose exactly the same problem but nothing worked for me. 我已经阅读了国内外所有可能的讨论,也发现该线程暴露了完全相同的问题,但对我没有任何帮助。
Any help is appreciated thanks! 任何帮助表示赞赏,谢谢!
我认为这是拼写错误, mycarmanev
或mycarmavirtuanev
吗?
WSGIDaemonProcess mycarma python-path=/home/carma/mycarma/ python-home=/home/carma/mycarma/myprojectenv
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.