I am new to deploying the Django project on cpanel. My cpanel was on python 2.7 but my project need python3.7 so I have installed a separate version of python 3.7 on cpanel by following this tutorial https://sysally.com/blog/install-python-3-x-whm-cpanel-server/ .After successfully installing python 3.7 I followed this tutorial to server my project on cpanel https://docs.cpanel.net/knowledge-base/web-services/how-to-install-a-python-wsgi-application/ Firstly I was getting this error "ImportError: No module named django.core.wsgi" which i have solved by adding my virtual environment path to wsgi.py file , now my project wsgi.py file looks like this
import os, sys
# add the virtualenv site-packages path to the sys.path
sys.path.append('/home/***/public_html/app/unltdenv/lib/python3.7/site-packages')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'unltdsample.settings')
application = get_wsgi_application()
Now I am getting this error
Traceback (most recent call last):
File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 369, in <module>
app_module = load_app()
File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 76, in load_app
return imp.load_source('passenger_wsgi', startup_file)
File "/home/umadmin/public_html/app/unltd/passenger_wsgi.py", line 1, in <module>
from unltdsample.wsgi import application
File "/home/umadmin/public_html/app/unltd/unltdsample/wsgi.py", line 19, in <module>
from django.core.wsgi import get_wsgi_application
File "/home/umadmin/public_html/app/unltdenv/lib/python3.7/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/home/umadmin/public_html/app/unltdenv/lib/python3.7/site-packages/django/utils/version.py", line 71, in <module>
@functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
i have searched about it, what i found is that the problem is of wsgi python version mismatch. And by running this commands i can fix this issue
$ sudo apt-get remove libapache2-mod-python libapache2-mod-wsgi
$ sudo apt-get install libapache2-mod-wsgi-py3
but when i run this command in terminal i get
"sudo: apt-get: command not found"
when i run this with yum i get
No Match for argument: libapache2-mod-python
No Match for argument: libapache2-mod-wsgi
No Packages marked for removal
i have also tried to install with pip install mod-wsgi
in my virtual environment it installed successfully, but the error do not solved.
can any body helps me solving this issue..
System Details :
Python 3.7.0 (default, Sep 29 2020, 12:40:13) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Django Version :3.1.1
Server version: Apache/2.4.46 (cPanel) Server built: Sep 22 2020 19:31:16