[英]ModuleNotFoundError: No module named 'django', with virtual environment Python3.8
尝试在 Python3.8 虚拟环境中运行 Django 应用程序和 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] 从 django.core.wsgi import get_wsgi_application [Sun May 03 02:56:14.2092] [wsgi:2092]错误] [pid 21516] [远程192.168.1.5:58968] ModuleNotFoundError:没有名为“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()
默认.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>
我关注了一些故障排除文章,但没有运气
try to install Django
using the following command in windows CMD, and then try to execute it again: python -m django
我希望这有效:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.