django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2._psycopg'

My site was working well in cpanel. when i add it to google search console for seo, after one day I am seeing such error:

We’re sorry, but something went wrong.

The issue has been logged for investigation. Please try again later.

Here is my Passengers.py file

My os is Windows. Please help guys. I would be very grateful.

I installed psycopg2-binary as psycopg2 didnt work.

@ShokhjahonNosirov
Hey buddy it will be easier to help if you insert the code and errors here instead of image.

1 Like

terminal error:
App 150054 output: /opt/cpanel/ea-ruby27/root/usr/share/passenger/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module’s documentation for alternative uses
App 150054 output: import sys, os, re, imp, threading, signal, traceback, socket, select, struct, logging, errno
App 150054 output: Traceback (most recent call last):
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/db/backends/postgresql/base.py”, line 25, in
App 150054 output: import psycopg2 as Database
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib64/python3.8/site-packages/psycopg2/init.py”, line 51, in
App 150054 output: from psycopg2._psycopg import ( # noqa
App 150054 output: ModuleNotFoundError: No module named ‘psycopg2._psycopg’
App 150054 output: During handling of the above exception, another exception occurred:
App 150054 output: Traceback (most recent call last):
App 150054 output: File “/opt/cpanel/ea-ruby27/root/usr/share/passenger/helper-scripts/wsgi-loader.py”, line 369, in
App 150054 output: app_module = load_app()
App 150054 output: File “/opt/cpanel/ea-ruby27/root/usr/share/passenger/helper-scripts/wsgi-loader.py”, line 76, in load_app
App 150054 output: return imp.load_source(‘passenger_wsgi’, startup_file)
App 150054 output: File “/opt/alt/python38/lib64/python3.8/imp.py”, line 171, in load_source
App 150054 output: module = _load(spec)
App 150054 output: File “”, line 702, in _load
App 150054 output: File “”, line 671, in _load_unlocked
App 150054 output: File “”, line 843, in exec_module
App 150054 output: File “”, line 219, in _call_with_frames_removed
App 150054 output: File “/home/host2646/config/passenger_wsgi.py”, line 15, in
App 150054 output: from config.wsgi import application
App 150054 output: File “/home/host2646/config/config/wsgi.py”, line 16, in
App 150054 output: application = get_wsgi_application()
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/core/wsgi.py”, line 12, in get_wsgi_application
App 150054 output: django.setup(set_prefix=False)
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/init.py”, line 24, in setup
App 150054 output: apps.populate(settings.INSTALLED_APPS)
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/apps/registry.py”, line 114, in populate
App 150054 output: app_config.import_models()
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/apps/config.py”, line 301, in import_models
App 150054 output: self.models_module = import_module(models_module_name)
App 150054 output: File “/opt/alt/python38/lib64/python3.8/importlib/init.py”, line 127, in import_module
App 150054 output: return _bootstrap._gcd_import(name[level:], package, level)
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/contrib/auth/models.py”, line 3, in
App 150054 output: from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/contrib/auth/base_user.py”, line 48, in
App 150054 output: class AbstractBaseUser(models.Model):
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/db/models/base.py”, line 122, in new
App 150054 output: new_class.add_to_class(‘_meta’, Options(meta, app_label))
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/db/models/base.py”, line 326, in add_to_class
App 150054 output: value.contribute_to_class(cls, name)
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/db/models/options.py”, line 207, in contribute_to_class
App 150054 output: self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/utils/connection.py”, line 15, in getattr
App 150054 output: return getattr(self._connections[self._alias], item)
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/utils/connection.py”, line 62, in getitem
App 150054 output: conn = self.create_connection(alias)
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/db/utils.py”, line 204, in create_connection
App 150054 output: backend = load_backend(db[‘ENGINE’])
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/db/utils.py”, line 111, in load_backend
App 150054 output: return import_module(‘%s.base’ % backend_name)
App 150054 output: File “/opt/alt/python38/lib64/python3.8/importlib/init.py”, line 127, in import_module
App 150054 output: return _bootstrap._gcd_import(name[level:], package, level)
App 150054 output: File “/home/host2646/virtualenv/config/3.8/lib/python3.8/site-packages/django/db/backends/postgresql/base.py”, line 29, in
App 150054 output: raise ImproperlyConfigured(“Error loading psycopg2 module: %s” % e)
App 150054 output: django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named ‘psycopg2._psycopg’

i still think it had caused by psycopg2-binary package or psycopg2, you need to make sure you installed it inside your virtual environment and it is activated.
Also make sure the package inside your site installed packages, as i see you have python 3.8

lib64/python3.8/site-packages/psycopg2
1 Like