【发布时间】:2020-08-17 08:52:59
【问题描述】:
尝试在 Python3.8 虚拟环境中运行 Django App 和 Apache2。当我进入 python shell 时,我可以导入 django。但是访问网页时,它说“django not found”
根据 /var/log/apache2/error.log,以下是错误
[Sun May 03 02:56:14.209910 2020] [wsgi:error] [pid 21516] [remote 192.168.1.5:58968] from django.core.wsgi import get_wsgi_application [Sun May 03 02:56:14.209966 2020] [wsgi:error] [pid 21516] [remote 192.168.1.5:58968] ModuleNotFoundError: No module named 'django'
wsgi.py:
导入操作系统,系统
sys.path.append('/var/www/html/django-venv-py3.8/lib/python3.8/site-packages')
从 django.core.wsgi 导入 get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'filebucket.settings')
应用程序 = get_wsgi_application()
default.conf
(django-venv-py3.8) ramesh@Orktion:.../filebucket$ cat /etc/apache2/sites-available/000-default.conf
<Directory /var/www/html/django-venv-py3.8/filebucket/filebucket>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess filebucket python-path=/var/www/html/django-venv-py3.8/filebucket python-home=/var/www/html/django-venv-py3.8
WSGIProcessGroup filebucket
WSGIScriptAlias / /var/www/html/django-venv-py3.8/filebucket/filebucket/wsgi.py
Alias /static /var/www/html/django-venv-py3.8/filebucket/static
<Directory /var/www/html/django-venv-py3.8/filebucket/static>
Require all granted
</Directory>
Alias /media /var/www/html/django-venv-py3.8/filebucket/media
<Directory /var/www/html/django-venv-py3.8/filebucket/media>
Require all granted
</Directory>
我关注了一些故障排除文章,但没有运气
【问题讨论】: