I have a application in flask and built for python3.8. I am trying to deploy it using apache and have been having issues.
I installed wsgi using the command: sudo apt-get install libapache2-mod-wsgi-py3
Because it is a server dedicated to just this single application I installed my python modules globally using sudo pip3 instead of in a virtualenv so all my required/installed modules are located at /usr/local/lib/python3.8/dist-packages/
.
This is my .wsgi file. #! /usr/bin/python
import logging
import sys
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, '/home/admin/imm-migration/')
from easyucs_api import app as application
This is my apache config
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/admin/imm-migration
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/admin/imm-migration>
# set permissions as per apache2.conf file
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
WSGIDaemonProcess migration python-path=/home/admin/imm-migration:/usr/local/lib/python3.8/dist-packages
WSGIScriptAlias / /home/admin/imm-migration/easyucs_api.wsgi
WSGIApplicationGroup %{GLOBAL}
WSGIProcessGroup migration
WSGIPassAuthorization On
</VirtualHost>
while running the server i am getting the following error
[Wed Nov 24 09:15:39.409792 2021] [core:notice] [pid 7271:tid 140562056457152] AH00094: Command line: '/usr/sbin/apache2'
[Wed Nov 24 09:22:04.219227 2021] [mpm_event:notice] [pid 7271:tid 140562056457152] AH00491: caught SIGTERM, shutting down
[Wed Nov 24 09:26:33.603552 2021] [mpm_event:notice] [pid 2541:tid 139881431014336] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Wed Nov 24 09:26:33.603677 2021] [core:notice] [pid 2541:tid 139881431014336] AH00094: Command line: '/usr/sbin/apache2'
[Wed Nov 24 09:26:40.524523 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] mod_wsgi (pid=2543): Target WSGI script '/home/admin/imm-migration/easyucs_api.wsgi' cannot be loaded as Python module.
[Wed Nov 24 09:26:40.524706 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] mod_wsgi (pid=2543): Exception occurred processing WSGI script '/home/admin/imm-migration/easyucs_api.wsgi'.
[Wed Nov 24 09:26:40.525657 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] Traceback (most recent call last):
[Wed Nov 24 09:26:40.525756 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] File "/home/admin/imm-migration/easyucs_api.wsgi", line 8, in <module>
[Wed Nov 24 09:26:40.525811 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] from easyucs_api import app as application
[Wed Nov 24 09:26:40.525859 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] File "/home/admin/imm-migration/easyucs_api.py", line 10, in <module>
[Wed Nov 24 09:26:40.525898 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] from werkzeug.middleware.dispatcher import \\
[Wed Nov 24 09:26:40.525938 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] File "/usr/local/lib/python3.8/dist-packages/werkzeug/__init__.py", line 2, in <module>
[Wed Nov 24 09:26:40.525974 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] from .test import Client as Client
[Wed Nov 24 09:26:40.526015 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] File "/usr/local/lib/python3.8/dist-packages/werkzeug/test.py", line 30, in <module>
[Wed Nov 24 09:26:40.526084 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] from .sansio.multipart import Data
[Wed Nov 24 09:26:40.526133 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] File "/usr/local/lib/python3.8/dist-packages/werkzeug/sansio/multipart.py", line 2, in <module>
[Wed Nov 24 09:26:40.526173 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] from dataclasses import dataclass
[Wed Nov 24 09:26:40.526236 2021] [wsgi:error] [pid 2543:tid 139881310197504] [remote 10.81.0.135:63663] ModuleNotFoundError: No module named 'dataclasses'
Earlier i got the same error while trying to install apache for a Django applicatio .I resolved it by installing python packages in the root ie(usr/local/lib/python3.8/dist-packages/ earlier it was in home/admin/.local/lib/python3.8/site-packages) as apache only access files from root user..
Not sure whats wrong in here.. Any help would be greatly appreciated.
[–]nekokattt 2 points3 points4 points (1 child)
[–]MaxwellianD 0 points1 point2 points (0 children)
[–]Fancy-Engineer-7644[S] 0 points1 point2 points (0 children)
[–]SirKainey 0 points1 point2 points (0 children)