Apache2 not runing django error ImportError: No module named site

sudo vi /etc/httpd/conf.d/canon.conf

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName your_domain_or_ip

# Path to the root of your Django app
DocumentRoot /home/ec2-user/erp-edi-integration/canon

# Update to the new virtual environment path
WSGIDaemonProcess canon python-home=/home/virtual-env/venv
WSGIProcessGroup canon

WSGIScriptAlias / /home/ec2-user/erp-edi-integration/canon/canon/wsgi.py

# Set up static files
Alias /static/ /home/ec2-user/erp-edi-integration/canon/static/
<Directory /home/ec2-user/erp-edi-integration/canon/static>
    Require all granted
</Directory>

# Set up media files
Alias /media/ /home/ec2-user/erp-edi-integration/canon/media/
<Directory /home/ec2-user/erp-edi-integration/canon/media>
    Require all granted
</Directory>

<Directory /home/ec2-user/erp-edi-integration/canon/canon>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

canon/wsgi.py

import os, sys
sys.path.insert(0, '/home/ec2-user/erp-edi-integration/canon')
sys.path.insert(0, '/home/virtual-env/venv/lib/python3.9/site-packages')
sys.path.insert(0, '/home/virtual-env/venv/lib/python3.9/lib-dynload')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'canon.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()


>>> import sys
>>> print(sys.path) 
['', '/home/ec2-user/miniconda3/envs/myenv/lib/python39.zip', '/home/ec2-user/miniconda3/envs/myenv/lib/python3.9', '/home/ec2-user/miniconda3/envs/myenv/lib/python3.9/lib-dynload', '/home/virtual-env/venv/lib/python3.9/site-packages']

all requirement already install

check virtual environment

source /home/virtual-env/venv/bin/activate # Activate again

after all this when i run my server restart then in apache log error show me this ImportError: No module named site

what is wrong in this

my project path is /home/ec2-user/erp-edi-integration/canon/canon/wsgi.py

Вернуться на верх