0

I want to deploy Djanogo Celery application, and I encountered error ModuleNotFoundError: No module named Xyz but when I go to folder where is manage.py is and run python3 manage.py runserver I can see that server is running on port 8000 locally, but

   mod_wsgi (pid=25901): Failed to exec Python script file '/var/www/celeryEnv/vcs_celery/parsing_hub/parsing_hub/wsgi.py'.
mod_wsgi (pid=25901): Exception occurred processing WSGI script '/var/www/celeryEnv/vcs_celery/parsing_hub/parsing_hub/wsgi.py'.
Traceback (most recent call last):
File "/var/www/celeryEnv/vcs_celery/parsing_hub/parsing_hub/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
File "/var/www/celeryEnv/lib64/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
File "/var/www/celeryEnv/lib64/python3.6/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/var/www/celeryEnv/lib64/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
File "/var/www/celeryEnv/lib64/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
File "/var/www/celeryEnv/lib64/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'parsing_hub'

I have virtualenv configured with python3 -m venv celeryEnv

my config in /etc/httpd/conf.d/celery.conf is this:

<VirtualHost *:8099>
    ServerName server
    ServerAlias server
    ServerAdmin admin@admin.com
    DocumentRoot /var/www/vcs_celery/parsing_hub

    WSGIDaemonProcess celeryEnv python-path=/var/www/celeryEnv/lib/python3.6/site-packages user=apache group=apache python-home=/var/www/celeryEnv
    WSGIProcessGroup celeryEnv
    WSGIScriptAlias / /var/www/vcs_celery/parsing_hub/parsing_hub/wsgi.py

    ErrorLog /var/www/logs/error.log
    CustomLog /var/www/logs/custom.log combined

    Alias /static /var/www/celery/vcs_celery/parsing_hub/static
    <Directory /var/www/celery/vcs_celery/parsing_hub/static>
        Require all granted
    </Directory>
</VirtualHost>

I think that apache is not recognizing vierualenv but because I'm beginner in setting up python wsgi I don't know what should I do to make it work, any help is welcome

EDIT i done this Can't run Apache2 with virtualenv now i see apache see vietualenv but error is the same

EDIT 2

pip freeze

amqp==2.5.2
Babel==2.7.0
beautifulsoup4==4.6.0
billiard==3.5.0.5
celery==4.1.0
cffi==1.13.2
cryptography==2.8
cssselect==1.1.0
Django==2.0.4
django-bootstrap3==10.0.1
django-celery-beat==1.1.1
flower==0.9.2
geopy==1.11.0
jusText==2.2.0
kombu==4.1.0
lxml==4.4.1
mod-wsgi==4.6.8
mysqlclient==1.3.12
nltk==3.2.5
numpy==1.17.4
pandas==0.20.3
parsel==1.4.0
pycparser==2.19
pyOpenSSL==17.5.0
python-dateutil==2.8.1
python-gitlab==1.1.0
pytz==2019.3
requests==2.12.4
selenium==2.53.1
six==1.13.0
SQLAlchemy==1.1.13
tornado==6.0.3
urllib3==1.25.7
vine==1.3.0
w3lib==1.21.0

**EDIT 3 **

contents ofr wsgi.py file

"""
WSGI config for parsing_hub project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""

import os
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "parsing_hub.settings")

application = get_wsgi_application()
Viszman
  • 1,378
  • 1
  • 17
  • 47

1 Answers1

1

If you tested your syntax in your dev environment and everything is ok, then the problem is here

WSGIDaemonProcess celeryEnv python-path=/var/www/celeryEnv/lib/python3.6/site-packages user=apache group=apache python-home=/var/www/celeryEnv

apache only look at

python-path=/var/www/celeryEnv/lib/python3.6/site-packages

so any modules in lib64 will not be recognized in apache

I found a workaround by coping all modules in /var/www/celeryEnv/lib64 to /var/www/celeryEnv/lib

now apache will work here's the line from my own servers

WSGIDaemonProcess domain.com python-path=/home/user/app/env/lib/python3.6/site-packages:/home/user/app