Tôi đang sử dụng ubuntu 16.04 và đã cài đặt python 3.7 và đặt nó thành mặc định bằng cách sử dụng hướng dẫn sau: Không thể đặt phiên bản python mặc định thành python3 trong ubuntu khi tôi nhập python
vào bảng điều khiển, tôi nhận được python3.7, tôi đã cố gắng đặt appache2 để hoạt động với python 3.7 sử dụng:
sudo add-apt-repository --yes ppa:deadsnakes/ppa
sudo apt-get update --yes
sudo apt-get install --yes python3.7
sudo apt-get install --yes python3-pip
sudo apt-get --yes install python3-pip apache2 libapache2-mod-wsgi-py3
sudo a2enmod wsgi
sudo apt install --yes python-django-common
sudo apt-get install --yes python-django
nhưng tôi vẫn nhận được ngoại lệ của các gói nhập đã được cài đặt trong /var/log/apache2/error.log khi cố gắng liên hệ với máy chủ mà tôi không nhận được ở thiết bị đầu cuối như sau:
Traceback (most recent call last):
File "/home/ubuntu/my_code/wsgi.py", line 11, in <module>
from django.core.wsgi import get_wsgi_application
ImportError: No module named 'django'
mod_wsgi (pid=75005): Target WSGI script '/home/ubuntu/my_code/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=75005): Exception occurred processing WSGI script '/home/ubuntu/my_code/wsgi.py'.
Traceback (most recent call last):
File "/home/ubuntu/my_code/wsgi.py", line 11, in <module>
from django.core.wsgi import get_wsgi_application
và
mod_wsgi (pid=75005): Target WSGI script '/home/ubuntu/my_code/wsgi.py' cannot be loaded as Python module.
mặc dù tôi đã cài đặt django trong python 3.7 một lỗi khác mà tôi gặp phải là sau khi khởi động lại dịch vụ:
mod_wsgi (pid=89300): Call to 'site.addsitedir()' failed for '(null)', stopping.
wsgiy.py của tôi:
import os
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "servicesite.settings")
path='/home/ubuntu/my_code/'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_code.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Điều gì có thể là lý do cho lỗi này?