ModuleNotFoundError:没有名为“Django”的模块,具有虚拟环境Python3.8

2024-09-29 19:33:59 发布

您现在位置:Python中文网/ 问答频道 /正文

正在尝试在Python3.8虚拟环境中运行Django应用程序和Apache2。当我进入pythonshell时,我可以导入django。但当访问网页时,会显示“django未找到”

根据/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导入获取wsgi应用程序 [Sun May 03 02:56:14.209966 2020][wsgi:error][pid 21516][remote 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导入获取\u wsgi\u应用程序

os.environ.setdefault('DJANGO\u SETTINGS\u MODULE','filebucket.SETTINGS')

application=get\u wsgi\u 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>

enter image description here

我已经阅读了一些疑难解答文章,但运气不好


Tags: djangopy应用程序wsgivenvvarhtmlwww

热门问题