ModuleNotFoundError:在虚拟环境Python3.8中没有名为“ django”的模块

时间:2020-05-02 21:40:38

标签: python django apache

尝试在Python3.8虚拟环境中将Django App与Apache2一起运行。当我进入python shell时,我可以导入django。但是访问网页时,它显示“找不到django”

根据/var/log/apache2/error.log,以下是错误

[django.core.wsgi中的[Sun May 03 02:56:14.209910 2020] [wsgi:error] [pid 21516] [远程192.168.1.5:58968] import get_wsgi_application [Sun May 03 02:56:14.209966 2020] [wsgi:error] [pid 21516] [远程192.168.1.5:58968] ModuleNotFoundError:没有名为“ django”的模块

wsgi.py:

导入os,sys

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')

application = 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>

enter image description here

我关注了一些故障排除文章,但是没有运气

1 个答案:

答案 0 :(得分:-1)

尝试在Windows CMD中使用以下命令安装Django,然后尝试再次执行它: python -m django

我希望这能奏效:)

相关问题