Unable to install Django packages in Bitnami Django stack in AWS

Keywords: Django - AWS - Technical issue - Other
Description:
I’ve tried Bitnami Django in AWS Lightsail, it worked. Then I’ve tried to deploy my existing Django app which is using rest_framework package .

I’ve done what document says but I couldn’t solve this issue I’m facing in Apache ‘Internal Server Error’ but python web server works perfectly.

The error_log shows this

[Thu Nov 19 13:00:49.956648 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] mod_wsgi (pid=12732): Failed to exec Python script file '/opt/bitnami/projects/alymarket/alymarket/wsgi.py'.
[Thu Nov 19 13:00:49.956731 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] mod_wsgi (pid=12732): Exception occurred processing WSGI script '/opt/bitnami/projects/alymarket/alymarket/wsgi.py'.
[Thu Nov 19 13:00:49.957439 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] Traceback (most recent call last):
[Thu Nov 19 13:00:49.957493 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] File "/opt/bitnami/projects/alymarket/alymarket/wsgi.py", line 18, in
[Thu Nov 19 13:00:49.957502 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] application = get_wsgi_application()
[Thu Nov 19 13:00:49.957513 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] File "/opt/bitnami/python/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu Nov 19 13:00:49.957518 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] django.setup(set_prefix=False)
[Thu Nov 19 13:00:49.957527 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] File "/opt/bitnami/python/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
[Thu Nov 19 13:00:49.957532 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] apps.populate(settings.INSTALLED_APPS)
[Thu Nov 19 13:00:49.957540 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] File "/opt/bitnami/python/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
[Thu Nov 19 13:00:49.957545 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] app_config = AppConfig.create(entry)
[Thu Nov 19 13:00:49.957553 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] File "/opt/bitnami/python/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
[Thu Nov 19 13:00:49.957559 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] module = import_module(entry)
[Thu Nov 19 13:00:49.957566 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] File "/opt/bitnami/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
[Thu Nov 19 13:00:49.957572 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] return bootstrap.gcd_import(name[level:], package, level)
[Thu Nov 19 13:00:49.957580 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] File "<frozen importlib.bootstrap>", line 1014, in _gcdimport
[Thu Nov 19 13:00:49.957588 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] File "<frozen importlib.bootstrap>", line 991, in _findand_load
[Thu Nov 19 13:00:49.957597 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] File "<frozen importlib.bootstrap>", line 973, in _findand_load_unlocked
[Thu Nov 19 13:00:49.957616 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:55598] ModuleNotFoundError: No module named 'rest_framework'
[Thu Nov 19 13:00:50.259705 2020] [authz_core:error] [pid 12733] [client 162.158.23.21:56432] AH01630: client denied by server configuration: /opt/bitnami/projects/alymarket/static, referer: 'domain'
[Thu Nov 19 13:00:51.045005 2020] [mpm_prefork:error] [pid 12728] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
[Thu Nov 19 15:00:51.424560 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] mod_wsgi (pid=12731): Failed to exec Python script file '/opt/bitnami/projects/alymarket/alymarket/wsgi.py'.
[Thu Nov 19 15:00:51.424632 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] mod_wsgi (pid=12731): Exception occurred processing WSGI script '/opt/bitnami/projects/alymarket/alymarket/wsgi.py'.
[Thu Nov 19 15:00:51.425322 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] Traceback (most recent call last):
[Thu Nov 19 15:00:51.425375 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] File "/opt/bitnami/projects/alymarket/alymarket/wsgi.py", line 18, in
[Thu Nov 19 15:00:51.425385 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] application = get_wsgi_application()
[Thu Nov 19 15:00:51.425395 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] File "/opt/bitnami/python/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu Nov 19 15:00:51.425400 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] django.setup(set_prefix=False)
[Thu Nov 19 15:00:51.425408 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] File "/opt/bitnami/python/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
[Thu Nov 19 15:00:51.425414 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] apps.populate(settings.INSTALLED_APPS)
[Thu Nov 19 15:00:51.425422 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] File "/opt/bitnami/python/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
[Thu Nov 19 15:00:51.425427 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] app_config = AppConfig.create(entry)
[Thu Nov 19 15:00:51.425434 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] File "/opt/bitnami/python/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
[Thu Nov 19 15:00:51.425440 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] module = import_module(entry)
[Thu Nov 19 15:00:51.425447 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] File "/opt/bitnami/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
[Thu Nov 19 15:00:51.425452 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] return bootstrap.gcd_import(name[level:], package, level)
[Thu Nov 19 15:00:51.425460 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] File "<frozen importlib.bootstrap>", line 1014, in _gcdimport
[Thu Nov 19 15:00:51.425468 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] File "<frozen importlib.bootstrap>", line 991, in _findand_load
[Thu Nov 19 15:00:51.425476 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] File "<frozen importlib.bootstrap>", line 973, in _findand_load_unlocked
[Thu Nov 19 15:00:51.425495 2020] [wsgi:error] [pid 12731] [remote 162.158.23.21:57818] ModuleNotFoundError: No module named 'rest_framework'
[Thu Nov 19 13:00:51.694399 2020] [authz_core:error] [pid 12737] [client 162.158.23.21:58748] AH01630: client denied by server configuration: /opt/bitnami/projects/alymarket/static, referer: 'domain'
[Thu Nov 19 15:01:40.768794 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] mod_wsgi (pid=12732): Failed to exec Python script file '/opt/bitnami/projects/alymarket/alymarket/wsgi.py'.
[Thu Nov 19 15:01:40.768869 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] mod_wsgi (pid=12732): Exception occurred processing WSGI script '/opt/bitnami/projects/alymarket/alymarket/wsgi.py'.
[Thu Nov 19 15:01:40.769087 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] Traceback (most recent call last):
[Thu Nov 19 15:01:40.769150 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] File "/opt/bitnami/projects/alymarket/alymarket/wsgi.py", line 18, in
[Thu Nov 19 15:01:40.769158 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] application = get_wsgi_application()
[Thu Nov 19 15:01:40.769167 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] File "/opt/bitnami/python/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu Nov 19 15:01:40.769172 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] django.setup(set_prefix=False)
[Thu Nov 19 15:01:40.769181 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] File "/opt/bitnami/python/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
[Thu Nov 19 15:01:40.769186 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] apps.populate(settings.INSTALLED_APPS)
[Thu Nov 19 15:01:40.769194 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] File "/opt/bitnami/python/lib/python3.8/site-packages/django/apps/registry.py", line 83, in populate
[Thu Nov 19 15:01:40.769199 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] raise RuntimeError("populate() isn't reentrant")
[Thu Nov 19 15:01:40.769216 2020] [wsgi:error] [pid 12732] [remote 162.158.23.21:24302] RuntimeError: populate() isn't reentrant
[Thu Nov 19 13:01:40.949113 2020] [authz_core:error] [pid 12735] [client 162.158.23.21:24652] AH01630: client denied by server configuration: /opt/bitnami/projects/alymarket/static, referer: 'domain'

Hi @msayed,

Did you configure wsgi.py as described in this section of the documentation?

https://docs.bitnami.com/general/infrastructure/django/get-started/deploy-django-project/#enable-wsgi-configuration-for-the-django-application

Could you check it?

If that doesn’t work could you run the bnsopport tool so I can check your configuration?

sudo /opt/bitnami/bnsupport-tool

Regards,
Michiel

Hi @michiel

I already fixed that.

The problem is that ‘python install packages in a location that apache do not see’.

so: packages get installed in ‘/home/bitnami/.local/lib/python3.8/site-packages/’ and Apache looks in ‘/opt/bitnami/python/lib/python3.8/site-packages/’.

The temporary solution I followed is copying packages to Apache eyes folder with this command ‘cp -r /home/bitnami/.local/lib/python3.8/site-packages/* /opt/bitnami/python/lib/python3.8/site-packages/’

1 Like

Hi @msayed,

I’m glad to hear you found the solution. Thanks for sharing. :smile:

Regards,
Michiel

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.