ansible-community / ara

ARA Records Ansible and makes it easier to understand and troubleshoot.

Home Page:https://ara.recordsansible.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

1.7.0rc3 - ModuleNotFoundError: No module named 'ara'

hille721 opened this issue · comments

I just wanted to rest the new ara version 1.7.3 but ara is not starting with ModuleNotFoundError: No module named 'ara' error.

This is the full output when starting ara:

[ara] No setting found for SECRET_KEY. Generating a random key...
[ara] Writing default settings to /opt/ara/settings.yaml
[ara] Using settings file: /opt/ara/settings.yaml
Operations to perform:
  Apply all migrations: admin, api, auth, contenttypes, db, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying api.0001_initial... OK
  Applying api.0002_remove_host_alias... OK
  Applying api.0003_add_missing_result_properties... OK
  Applying api.0004_duration_in_database... OK
  Applying api.0005_unique_label_names... OK
  Applying api.0006_remove_result_statuses... OK
  Applying api.0007_add_expired_status... OK
  Applying api.0008_playbook_controller... OK
  Applying api.0009_latesthost... OK
  Applying api.0010_result_delegated_to... OK
  Applying api.0011_play_label_name_max_length... OK
  Applying api.0012_playbook_user... OK
  Applying api.0013_task_status... OK
  Applying api.0014_ara_versions... OK
  Applying api.0015_task_uuid... OK
  Applying api.0016_revert_play_label_name_length... OK
  Applying api.0017_optional_playbook_controller... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying db.0001_initial... OK
  Applying sessions.0001_initial... OK
[2023-09-11 13:26:04 +0000] [1] [INFO] Starting gunicorn 20.1.0
[2023-09-11 13:26:04 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2023-09-11 13:26:04 +0000] [1] [INFO] Using worker: gthread
[2023-09-11 13:26:04 +0000] [8] [INFO] Booting worker with pid: 8
[2023-09-11 13:26:04 +0000] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/usr/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
    super().init_process()
  File "/usr/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/usr/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/usr/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'ara'

I'm using a own company container image based on Rhel9 and doing basically the same as in https://github.com/ansible-community/ara/blob/master/contrib/container-images/centos-pypi.sh.

bash-5.1$ python3 --version
Python 3.9.16
bash-5.1$ pip freeze 
ara==1.7.0.0rc3
asgiref==3.7.2
attrs==23.1.0
autopage==0.5.1
chardet==4.0.0
cliff==4.3.0
cmd2==2.4.3
dbus-python==1.2.18
decorator==4.4.2
Django==4.2.5
django-cors-headers==4.2.0
django-filter==23.2
django-health-check==3.17.0
djangorestframework==3.14.0
dynaconf==3.2.2
ethtool==0.15
gpg==1.15.1
gunicorn==20.1.0
idna==2.10
importlib-metadata==6.8.0
iniparse==0.4
libcomps==0.1.18
mysqlclient==2.1.0
pbr==5.11.1
prettytable==3.8.0
psycopg2==2.8.6
Pygments==2.16.1
PyGObject==3.40.1
pyinotify==0.9.6
pyperclip==1.8.2
PySocks==1.7.1
python-dateutil==2.8.1
pytz==2023.3.post1
PyYAML==6.0.1
requests==2.25.1
rpm==4.16.1.3
ruamel.yaml==0.17.32
ruamel.yaml.clib==0.2.7
six==1.15.0
sqlparse==0.4.4
stevedore==5.1.0
subscription-manager==1.29.33.1
systemd-python==234
typing_extensions==4.8.0rc1
tzlocal==5.0.1
urllib3==1.26.5
wcwidth==0.2.6
whitenoise==6.5.0
zipp==3.16.2

Could be related to different installation directories of ara and gunicorn:

[root@5314d0c4100c ~]# which ara
/usr/local/bin/ara
[root@5314d0c4100c ~]# which gunicorn
/usr/bin/gunicorn

Also just verified, the problem is not only related to 1.7 but more dependent that I updated my base image from Rhel8 to Rhel9 to have Python 3.9.

I already find a easy fix:

Instead of running gunicorn via /usr/bin/gunicorn, running it via python3 -m gunicorn. This works.

ah damn, just realized that you also run into that issue a year ago :)
#406 (comment)

Thus I will close this, but will provide a PR to change the gunicorn command to python3 -m gunicorn which is probably still a good idea to do it like it, to be safe in the future.