import psycopg2 : SystemError: initialization of _psycopg raised unreported exception\r on 2nd URL hit fails - python-3.x

I have two url to my application, which refers to same eg: localhost:8080 and abc.com. Pattern is that after restarting the apache server, only the first one URL works which I hit first and 2nd url does not work. Ideally both should work as both refers to same server.
I am getting below error for python 3.9. After following this I uninstalled and installed mod_wsgi 4.7.1 using python 3.9 pip and updated apache httpd.conf with output of mod_wsgi-express.exe module-config
[Mon May 24 04:31:30.115963 2021] [mpm_winnt:notice] [pid 8560:tid 104] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Mon May 24 04:31:32.121364 2021] [mpm_winnt:notice] [pid 9452:tid 904] AH00364: Child: All worker threads have exited.
[Mon May 24 04:31:32.303380 2021] [mpm_winnt:notice] [pid 8560:tid 104] AH00430: Parent: Child process 9452 exited successfully.
[Mon May 24 04:31:33.770657 2021] [mpm_winnt:notice] [pid 612:tid 908] AH00455: Apache/2.4.46 (Win64) mod_wsgi/4.7.1 Python/3.9 configured -- resuming normal operations
[Mon May 24 04:31:33.771659 2021] [mpm_winnt:notice] [pid 612:tid 908] AH00456: Apache Lounge VS16 Server built: Mar 27 2021 11:42:37
[Mon May 24 04:31:33.771659 2021] [core:notice] [pid 612:tid 908] AH00094: Command line: 'F:\\Program Files\\NGDM\\Apache24\\bin\\httpd.exe -d F:/Program Files/NGDM/Apache24'
[Mon May 24 04:31:33.781650 2021] [mpm_winnt:notice] [pid 612:tid 908] AH00418: Parent: Created child process 10632
[Mon May 24 04:31:34.815778 2021] [mpm_winnt:notice] [pid 10632:tid 872] AH00354: Child: Starting 64 worker threads.
[Mon May 24 04:32:18.161398 2021] [wsgi:error] [pid 10632:tid 1440] RUN_ID==>51683<==\r
[Mon May 24 04:32:18.163398 2021] [wsgi:error] [pid 10632:tid 1440] RUN_ID==>51683<==\r
C:\A\34\s\Modules\_decimal\libmpdec\context.c:57: warning: mpd_setminalloc: ignoring request to set MPD_MINALLOC a second time
[Mon May 24 04:32:29.651626 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] mod_wsgi (pid=10632): Failed to exec Python script file 'F:/XYZ/test_wsgi.wsgi'.
[Mon May 24 04:32:29.651626 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] mod_wsgi (pid=10632): Exception occurred processing WSGI script 'F:/XYZ/test_wsgi.wsgi'.
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] Traceback (most recent call last):\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] File "F:/XYZ/test_wsgi.wsgi", line 6, in <module>\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] from app_e1 import app as application\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] File "f:/XYZ\\app_e1.py", line 6, in <module>\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] import psycopg2\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] File "c:\\python39\\lib\\site-packages\\psycopg2\\__init__.py", line 51, in <module>\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] from psycopg2._psycopg import ( # noqa\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] SystemError: initialization of _psycopg raised unreported exception\r

In My case, restarting the server after adding below line in httpd.conf fixed the issue with multiple python sub interpreter. Ref.
WSGIApplicationGroup %{GLOBAL}

Related

Django unspecified error when deploying on Apache2

Below is the error when I try deploy Django==3.2.12, wagtail==2.16.1, python 3.8.2, mod_wsgi 4.9 on a Debian 11 server. I have a full stack trace at the end.
class SimpleLazyObject(LazyObject):
TypeError: Error when calling the metaclass bases
'property' object is not callable
When I run this on my local dev machine which is a Mac it works just fine. I found someone with the exact same problem but no clarity about how it was resolved.
The resources I have been using to assist are 1, 2, 3, 4. I have tried installing mod_wsgi using pip and as well as from sources. Used various guides for Apache2 config. Upgraded from python 3.8 to 3.9 as well as downgraded to 3.7.
Create interpreter '0.0.0.0|'.
[Tue Mar 29 11:49:06.679710 2022] [wsgi:info] [pid 199764:tid 139683953432320] mod_wsgi (pid=199764): Adding '/var/www/html/portal' to path.
[Tue Mar 29 11:49:06.680057 2022] [wsgi:info] [pid 199764:tid 139683953432320] mod_wsgi (pid=199764): Adding '/var/www/html/portal/portalvenv/lib/python3.8/site-packages' to path.
[Tue Mar 29 11:49:06.689628 2022] [wsgi:info] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] mod_wsgi (pid=199764, process='saida-befree_portal', application='0.0.0.0|'): Loading Python script file '/var/www/html/portal/portal/wsgi.py'.
[Tue Mar 29 11:49:06.705081 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] mod_wsgi (pid=199764): Failed to exec Python script file '/var/www/html/portal/portal/wsgi.py'.
[Tue Mar 29 11:49:06.713633 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] mod_wsgi (pid=199764): Exception occurred processing WSGI script '/var/www/html/portal/portal/wsgi.py'.
[Tue Mar 29 11:49:06.713903 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] Traceback (most recent call last):
[Tue Mar 29 11:49:06.714017 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portal/wsgi.py", line 12, in <module>
[Tue Mar 29 11:49:06.714210 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] from django.core.wsgi import get_wsgi_application
[Tue Mar 29 11:49:06.714304 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/__init__.py", line 1, in <module>
[Tue Mar 29 11:49:06.717663 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] from django.utils.version import get_version
[Tue Mar 29 11:49:06.717837 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/utils/version.py", line 7, in <module>
[Tue Mar 29 11:49:06.718002 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] from django.utils.regex_helper import _lazy_re_compile
[Tue Mar 29 11:49:06.718072 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/utils/regex_helper.py", line 10, in <module>
[Tue Mar 29 11:49:06.718305 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] from django.utils.functional import SimpleLazyObject
[Tue Mar 29 11:49:06.720700 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/utils/functional.py", line 362, in <module>
[Tue Mar 29 11:49:06.721066 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] class SimpleLazyObject(LazyObject):
[Tue Mar 29 11:49:06.721539 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] TypeError: Error when calling the metaclass bases
[Tue Mar 29 11:49:06.721610 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] 'property' object is not callable
[Tue Mar 29 11:49:58.057546 2022] [reqtimeout:info] [pid 199765:tid 139683870795520] [client xx.xx.xx.xxx:yyyy] AH01382: Request header read timeout
I had the same issue so i did the following steps:
Remove the apache2 library by using the following command-
sudo apt-get remove python-pip apache2 libapache2-mod-wsgi
Then use the following command to install the correct library-
sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3
This solved my error.

WSGI permission error when deploying flask app to apache2

[Mon Jan 24 17:01:59.755348 2022] [wsgi:error] [pid 6837:tid 139969656289024] [remote xxx.xxx.xxx.xxx:xxxxx] mod_wsgi (pid=6837): Failed to exec Python script file '/var/www/FlaskDeliverN/app.wsgi'.
[Mon Jan 24 17:01:59.755407 2022] [wsgi:error] [pid 6837:tid 139969656289024] [remote xxx.xxx.xxx.xxx:xxxxx] mod_wsgi (pid=6837): Exception occurred processing WSGI script '/var/www/FlaskDeliverN/app.wsgi'.
[Mon Jan 24 17:01:59.760074 2022] [wsgi:error] [pid 6837:tid 139969656289024] [remote xxx.xxx.xxx.xxx:xxxxx] Traceback (most recent call last):
[Mon Jan 24 17:01:59.760109 2022] [wsgi:error] [pid 6837:tid 139969656289024] [remote xxx.xxx.xxx.xxx:xxxxx] File "/var/www/FlaskDeliverN/app.wsgi", line 5, in <module>
[Mon Jan 24 17:01:59.760114 2022] [wsgi:error] [pid 6837:tid 139969656289024] [remote xxx.xxx.xxx.xxx:xxxxx] with open(activate_this) as file_:
[Mon Jan 24 17:01:59.760129 2022] [wsgi:error] [pid 6837:tid 139969656289024] [remote xxx.xxx.xxx.xxx:xxxxx] PermissionError: [Errno 13] Permission denied: '/root/.local/share/virtualenvs/FlaskDeliverN-8O9_IGcY/bin/activate_this.py'
I keep on getting the above error. I am not sure why there would be a permission error here. I checked that the file existed and wasn't empty so that's not the issue. I have looked through many tutorials on how to deploy a flask app but it never works and I think this may be why.
I followed this tutorial:https://www.youtube.com/watch?v=w0QDAg85Oow

500 Internal server error "populate() isn't reentrant"

I am having issues with deploying some recent work on a Django app to my server. On deployment, I updated a few pip modules, and there was also some restructuring of the directories. Once done, I restarted apache2, but was greated by the below error messages which proved unhelpful
[Thu May 13 13:12:09.846428 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] mod_wsgi (pid=8385): Target WSGI script '/var/www/stage.admin.agile.coop/web/mysite/wsgi.py' cannot be loaded as Python module.
[Thu May 13 13:12:09.846751 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] mod_wsgi (pid=8385): Exception occurred processing WSGI script '/var/www/stage.admin.agile.coop/web/mysite/wsgi.py'.
[Thu May 13 13:12:09.847024 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] Traceback (most recent call last):
[Thu May 13 13:12:09.847174 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] File "/var/www/stage.admin.agile.coop/web/mysite/wsgi.py", line 16, in <module>
[Thu May 13 13:12:09.847275 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] application = get_wsgi_application()
[Thu May 13 13:12:09.847363 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] File "/var/www/stage.admin.agile.coop/venv/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu May 13 13:12:09.847460 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] django.setup(set_prefix=False)
[Thu May 13 13:12:09.847561 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] File "/var/www/stage.admin.agile.coop/venv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Thu May 13 13:12:09.847655 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] apps.populate(settings.INSTALLED_APPS)
[Thu May 13 13:12:09.847755 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] File "/var/www/stage.admin.agile.coop/venv/lib/python3.6/site-packages/django/apps/registry.py", line 83, in populate
[Thu May 13 13:12:09.847850 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] raise RuntimeError("populate() isn't reentrant.")
[Thu May 13 13:12:09.847944 2021] [wsgi:error] [pid 8385:tid 140483483444992] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] RuntimeError: populate() isn't reentrant.
[Thu May 13 13:12:10.281512 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] mod_wsgi (pid=8385): Target WSGI script '/var/www/stage.admin.agile.coop/web/mysite/wsgi.py' cannot be loaded as Python module.
[Thu May 13 13:12:10.281766 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] mod_wsgi (pid=8385): Exception occurred processing WSGI script '/var/www/stage.admin.agile.coop/web/mysite/wsgi.py'.
[Thu May 13 13:12:10.282035 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] Traceback (most recent call last):
[Thu May 13 13:12:10.282166 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] File "/var/www/stage.admin.agile.coop/web/mysite/wsgi.py", line 16, in <module>
[Thu May 13 13:12:10.282266 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] application = get_wsgi_application()
[Thu May 13 13:12:10.282360 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] File "/var/www/stage.admin.agile.coop/venv/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu May 13 13:12:10.282439 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] django.setup(set_prefix=False)
[Thu May 13 13:12:10.282550 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] File "/var/www/stage.admin.agile.coop/venv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Thu May 13 13:12:10.282626 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] apps.populate(settings.INSTALLED_APPS)
[Thu May 13 13:12:10.282704 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] File "/var/www/stage.admin.agile.coop/venv/lib/python3.6/site-packages/django/apps/registry.py", line 83, in populate
[Thu May 13 13:12:10.282791 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] raise RuntimeError("populate() isn't reentrant.") [Thu May 13 13:12:10.282883 2021] [wsgi:error] [pid 8385:tid 140483365897984] [remote 2a02:c7f:6c19:2c00:4150:e3c6:fe11:d603:34690] RuntimeError: populate() isn't reentrant.
On getting this, I followed some of the debugging tips on posts such as Django stops working with RuntimeError: populate() isn't reentrant which uncovered some modules to update in pip. Once done, those messages went away, but I still get this message.
Any further tips on how to debug this would be greatly received.
Dan
for this message ... RuntimeError("populate() isn't reentrant.") ... it is important to find the first error message in Apache error log file after restarting Apache. So please stop/start Apache and see if there is a different (another) error message first.
if there is nothing to find change registry.py like explained here and see if there is more clear error message:
Django stops working with RuntimeError: populate() isn't reentrant

Target WSGI script '/home/rajeshkumarponnu/Documents/OFFICE/IAB_PROJECT/iab_pro/wsgi.py' cannot be loaded as Python module

I am struggling to deploy the django rest api in apache with wsgi and getting 500 error. Here is my files, please suggest/help me where i am wrong.
Even so many facing same issues and i refered that also..but i could not able fix this error.
wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'iab_pro.settings')
application = get_wsgi_application()
000-default.conf:
<VirtualHost *:80>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName 192.0.18.111
ServerAdmin rajeshkumar.ponnusamy#indegene.com
WSGIScriptAlias / /home/rajeshkumarponnu/Documents/OFFICE/IAB_PROJECT/iab_pro/wsgi.py
<Directory /home/rajeshkumarponnu/Documents/OFFICE/IAB_PROJECT/iab_pro/>
<Files wsgi.py>
Require all granted
</Files>
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess IAB_PROJECT python-path=/home/rajeshkumarponnu/Documents/OFFICE/IAB_PROJECT python-home=/home/rajeshkumarponnu/Documents/OFFICE/venv_iab
WSGIProcessGroup IAB_PROJECT
</VirtualHost>
apache error log
[Fri Jan 10 12:14:57.407703 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] mod_wsgi (pid=17242): Target WSGI script '/home/rajeshkumarponnu/Documents/OFFICE/IAB_PROJECT/iab_pro/wsgi.py' cannot be loaded as Python module.
[Fri Jan 10 12:14:57.407764 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] mod_wsgi (pid=17242): Exception occurred processing WSGI script '/home/rajeshkumarponnu/Documents/OFFICE/IAB_PROJECT/iab_pro/wsgi.py'.
[Fri Jan 10 12:14:57.408932 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] Traceback (most recent call last):
[Fri Jan 10 12:14:57.408972 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/usr/lib/python3.6/logging/config.py", line 565, in configure
[Fri Jan 10 12:14:57.408978 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] handler = self.configure_handler(handlers[name])
[Fri Jan 10 12:14:57.408985 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/usr/lib/python3.6/logging/config.py", line 738, in configure_handler
[Fri Jan 10 12:14:57.408989 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] result = factory(**kwargs)
[Fri Jan 10 12:14:57.408995 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/usr/lib/python3.6/logging/__init__.py", line 1032, in __init__
[Fri Jan 10 12:14:57.408999 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] StreamHandler.__init__(self, self._open())
[Fri Jan 10 12:14:57.409007 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/usr/lib/python3.6/logging/__init__.py", line 1061, in _open
[Fri Jan 10 12:14:57.409011 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] return open(self.baseFilename, self.mode, encoding=self.encoding)
[Fri Jan 10 12:14:57.409028 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] FileNotFoundError: [Errno 2] No such file or directory: '/logs/error.log'
[Fri Jan 10 12:14:57.409037 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210]
[Fri Jan 10 12:14:57.409041 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] During handling of the above exception, another exception occurred:
[Fri Jan 10 12:14:57.409044 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210]
[Fri Jan 10 12:14:57.409050 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] Traceback (most recent call last):
[Fri Jan 10 12:14:57.409078 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/home/rajeshkumarponnu/Documents/OFFICE/IAB_PROJECT/iab_pro/wsgi.py", line 16, in <module>
[Fri Jan 10 12:14:57.409083 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] application = get_wsgi_application()
[Fri Jan 10 12:14:57.409092 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/home/rajeshkumarponnu/Documents/OFFICE/venv_iab/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Fri Jan 10 12:14:57.409096 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] django.setup(set_prefix=False)
[Fri Jan 10 12:14:57.409102 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/home/rajeshkumarponnu/Documents/OFFICE/venv_iab/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
[Fri Jan 10 12:14:57.409114 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Fri Jan 10 12:14:57.409121 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/home/rajeshkumarponnu/Documents/OFFICE/venv_iab/lib/python3.6/site-packages/django/utils/log.py", line 75, in configure_logging
[Fri Jan 10 12:14:57.409125 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] logging_config_func(logging_settings)
[Fri Jan 10 12:14:57.409131 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/usr/lib/python3.6/logging/config.py", line 802, in dictConfig
[Fri Jan 10 12:14:57.409135 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] dictConfigClass(config).configure()
[Fri Jan 10 12:14:57.409140 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] File "/usr/lib/python3.6/logging/config.py", line 573, in configure
[Fri Jan 10 12:14:57.409144 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] '%r: %s' % (name, e))
[Fri Jan 10 12:14:57.409155 2020] [wsgi:error] [pid 17242:tid 140717350381312] [remote 192.0.18.111:49210] ValueError: Unable to configure handler 'file': [Errno 2] No such file or directory: '/logs/error.log'
I am using python3.6 in my system, so installed
sudo apt-get install libapache2-mod-wsgi-py3
I have tried with www-data:www-data for venev folder and as well as project folder (IAB_PROJECT) and gave 777 permission for all folders. But still same error.
Thanks in advance.
This tutorial gives a concise walkthrough on how to go about running a Django Api on an apache server, maybe it'll give you a hint on how to solve the problem. Good luck.

How to install nltk on an Amazon EC2 instance?

I am trying to install nltk on an Amazon EC2 instance using pip and virtual environment. nltk is listed in the requirements.txt file that pip uses. I also want to download punkt using the nltk.download('punkt') option.
Here's what my makefile looks like:
INSTANCE_NAME=toolsapp
ENV=env
LOAD_ENV=source $(ENV)/bin/activate
VIRTUALENV_BIN:=$(shell which virtualenv || echo /usr/local/bin/virtualenv )
EB_BIN:=$(shell $(LOAD_ENV) && which eb || echo /usr/local/bin/eb )
AWS_BIN:=$(shell $(LOAD_ENV) && which aws || echo /usr/local/bin/aws )
default: dev
.PHONY: default
# Ensure virtualenv is installed
$(VIRTUALENV_BIN):
pip3 install virtualenv
# Create a virtualenv folder called env/ and install dependencies
$(ENV): $(VIRTUALENV_BIN)
virtualenv -p python3 $(ENV)
$(LOAD_ENV) && pip install --upgrade pip && pip install -r requirements.txt
But this is the error I get when I try to run the webapp:
[Tue Jul 24 14:46:13.798460 2018] [:error] [pid 22801] model type: 9
[Tue Jul 24 14:46:13.801193 2018] [:error] [pid 22801] Traceback (most recent call last):
[Tue Jul 24 14:46:13.801227 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/sumy/nlp/tokenizers.py", line 79, in _get_sentence_tokenizer
[Tue Jul 24 14:46:13.801232 2018] [:error] [pid 22801] return nltk.data.load(path)
[Tue Jul 24 14:46:13.801239 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/nltk/data.py", line 836, in load
[Tue Jul 24 14:46:13.801242 2018] [:error] [pid 22801] opened_resource = _open(resource_url)
[Tue Jul 24 14:46:13.801247 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/nltk/data.py", line 954, in _open
[Tue Jul 24 14:46:13.801251 2018] [:error] [pid 22801] return find(path_, path + ['']).open()
[Tue Jul 24 14:46:13.801255 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/nltk/data.py", line 675, in find
[Tue Jul 24 14:46:13.801259 2018] [:error] [pid 22801] raise LookupError(resource_not_found)
[Tue Jul 24 14:46:13.801274 2018] [:error] [pid 22801] LookupError:
[Tue Jul 24 14:46:13.801278 2018] [:error] [pid 22801] **********************************************************************
[Tue Jul 24 14:46:13.801280 2018] [:error] [pid 22801] Resource \x1b[93mpunkt\x1b[0m not found.
[Tue Jul 24 14:46:13.801283 2018] [:error] [pid 22801] Please use the NLTK Downloader to obtain the resource:
[Tue Jul 24 14:46:13.801285 2018] [:error] [pid 22801]
[Tue Jul 24 14:46:13.801288 2018] [:error] [pid 22801] \x1b[31m>>> import nltk
[Tue Jul 24 14:46:13.801299 2018] [:error] [pid 22801] >>> nltk.download('punkt')
[Tue Jul 24 14:46:13.801301 2018] [:error] [pid 22801] \x1b[0m
[Tue Jul 24 14:46:13.801303 2018] [:error] [pid 22801] Searched in:
[Tue Jul 24 14:46:13.801305 2018] [:error] [pid 22801] - '/home/wsgi/nltk_data'
[Tue Jul 24 14:46:13.801307 2018] [:error] [pid 22801] - '/usr/share/nltk_data'
[Tue Jul 24 14:46:13.801310 2018] [:error] [pid 22801] - '/usr/local/share/nltk_data'
[Tue Jul 24 14:46:13.801312 2018] [:error] [pid 22801] - '/usr/lib/nltk_data'
[Tue Jul 24 14:46:13.801314 2018] [:error] [pid 22801] - '/usr/local/lib/nltk_data'
[Tue Jul 24 14:46:13.801316 2018] [:error] [pid 22801] - '/opt/python/run/venv/nltk_data'
[Tue Jul 24 14:46:13.801318 2018] [:error] [pid 22801] - '/opt/python/run/venv/share/nltk_data'
[Tue Jul 24 14:46:13.801320 2018] [:error] [pid 22801] - '/opt/python/run/venv/lib/nltk_data'
[Tue Jul 24 14:46:13.801322 2018] [:error] [pid 22801] - ''
[Tue Jul 24 14:46:13.801325 2018] [:error] [pid 22801] **********************************************************************
[Tue Jul 24 14:46:13.801327 2018] [:error] [pid 22801]
[Tue Jul 24 14:46:13.801342 2018] [:error] [pid 22801]
[Tue Jul 24 14:46:13.801345 2018] [:error] [pid 22801] During handling of the above exception, another exception occurred:
[Tue Jul 24 14:46:13.801348 2018] [:error] [pid 22801]
[Tue Jul 24 14:46:13.801352 2018] [:error] [pid 22801] Traceback (most recent call last):
[Tue Jul 24 14:46:13.801369 2018] [:error] [pid 22801] File "/opt/python/current/app/summarization.py", line 40, in reform
[Tue Jul 24 14:46:13.801372 2018] [:error] [pid 22801] parser = HtmlParser.from_url(inputFile, Tokenizer("english"))
[Tue Jul 24 14:46:13.801377 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/sumy/nlp/tokenizers.py", line 67, in __init__
[Tue Jul 24 14:46:13.801380 2018] [:error] [pid 22801] self._sentence_tokenizer = self._get_sentence_tokenizer(tokenizer_language)
[Tue Jul 24 14:46:13.801385 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/sumy/nlp/tokenizers.py", line 82, in _get_sentence_tokenizer
[Tue Jul 24 14:46:13.801388 2018] [:error] [pid 22801] "NLTK tokenizers are missing. Download them by following command: "
[Tue Jul 24 14:46:13.801397 2018] [:error] [pid 22801] LookupError: NLTK tokenizers are missing. Download them by following command: python -c "import nltk; nltk.download('punkt')"
[Tue Jul 24 14:46:13.801414 2018] [:error] [pid 22801] unable to read https://webapp-input.s3.amazonaws.com/43629be5a07a43029f359abd1340ad08.input.txt?AWSAccessKeyId=ASIAI4UVLLOHEUNNKWNQ&Signature=NBbRoAhFB5mP3SNi3jR6rDcz8LY%3D&x-amz-security-token=FQoDYXdzEHgaDKt%2FFOhHU4UQgQLgdCK3A3amyJ9mziqpLJ01DR5yYqszDzAfi8e9B9Uj1xw9pJw4yDqyF5KFtul7D7o6Xm2qX%2FQvSb9tbnMoW2r8Pur%2FbhlJnhfKFUriT6ggk0THgAgXQWQ8pDOIIMOjn7XZLtFvTfWttukS40VC17geWmEod%2FsO9IZh3LyhN46V%2FdDQo21YZfZFRoQbFHgTd823mnnTLwNoZs51B%2BluwOJ70U22P0K%2FdhzFGVEEGj%2FDiT1oC%2B1aGHQoK4h9JC45%2BqdetOoxZZsdc2z8hxFPQbTW59AT2L4PC2icjkzjJ9prhJvzU25iuZeYoO5tC3SZ1fpNtJ5QCiBYdK1R1c0TRygeOGbev24j5qlTb5DLG4HknH47S6XBMKE%2Fs4EyEo2zNbu%2Fg7QhcebwjJ9%2FMcCpmbMV60H2cj2zMxk8gzV83E%2B19CODShcUQ7WSmNcXj5dyupEJ8SCHRBABBXhOZ8wzMLwU%2BgJy59DTzXl7ZZH1t0LzaOQLPSvjdqu%2FPNGhn1M7K4vVNti93hOCWsK0T3tltg9gfIjFF90gHSawS708WvcyUTmN%2BLD7m3cMJ9B9g9adISSU5d4NS7ohPyX%2FEQMom%2FDc2gU%3D&Expires=1532447173.
Add scripts to download the required models after installing nltk.
python3 -m nltk.downloader punkt
python3 -m nltk.downloader stopwords

Resources