Yes, found a solution,

Copypython -m pip install psycopg2-binary 

does the trick!

Answer from arilwan on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-modulenotfounderror-no-module-named-psycopg2-in-python
How to Fix 'ModuleNotFoundError: No Module Named psycopg2' in Python - GeeksforGeeks
July 23, 2025 - Another reason for the error might be a typo or incorrect naming when trying to import the psycopg2 module. Python is case-sensitive, so ensure that the module name is spelled correctly. ... Below, are the approaches to solve “Modulenotfounderror: No Module Named ‘psycopg2′”.
Discussions

python - ModuleNotFoundError: No module named 'psycopg2' macOS - Stack Overflow
Each time I run my script, I get this error % python new_monthly_donations.py Traceback (most recent call last): File "/Users/bdohman/Desktop/uway payments/scripts/new_monthly_donations.py&q... More on stackoverflow.com
🌐 stackoverflow.com
python 3.x - ModuleNotFoundError: No module named psycopg2 after installing package on Mac - Stack Overflow
I'm on macOS Monterrey version 12.4. I've installed the package psycopg2 with the command pip3 install psycopg2. The output of the installation is DEPRECATION: Configuring installation scheme with More on stackoverflow.com
🌐 stackoverflow.com
Error loading psycopg2 module: No module named 'psycopg2'
Hi all, First of all, I've read all the posts I could find about this problem to no avail :( I've got an up&running default webapp with python3 and django already working with default d... More on github.com
🌐 github.com
9
May 26, 2021
python - ImportError: No module named psycopg2 - Stack Overflow
In installation process of OpenERP 6, I want to generate a config file with these commands: cd /home/openerp/openerp-server/bin/ ./openerp-server.py -s --stop-after-init -c /home/openerp/openerp-s... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Stack Overflow
stackoverflow.com › questions › 75194835 › modulenotfounderror-no-module-named-psycopg2-macos
python - ModuleNotFoundError: No module named 'psycopg2' macOS - Stack Overflow
Name: psycopg2-binary Version: 2.9.5 Summary: psycopg2 - Python-PostgreSQL Database Adapter Home-page: https://psycopg.org/ Author: Federico Di Gregorio Author-email: [email protected] License: LGPL with exceptions Location: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages Requires: Required-by: % pip3 show psycopg2 Name: psycopg2 Version: 2.9.5 Summary: psycopg2 - Python-PostgreSQL Database Adapter Home-page: https://psycopg.org/ Author: Federico Di Gregorio Author-email: [email protected] License: LGPL with exceptions Location: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages Requires: Required-by: `
🌐
Stack Overflow
stackoverflow.com › questions › 73951443 › modulenotfounderror-no-module-named-psycopg2-after-installing-package-on-mac
python 3.x - ModuleNotFoundError: No module named psycopg2 after installing package on Mac - Stack Overflow
Can't install psycopg2 package through pip install on MacOS · 6 · ModuleNotFoundError: No module named 'psycopg2' 1 · How to use pip3 install psycopg2? 2 · ModuleNotFoundError: No module named 'psycopg2' (python3, mac, pip3 shows psycopg2 successfully installed) 0 ·
🌐
Bobby Hadz
bobbyhadz.com › blog › python-no-module-named-psycopg2
ModuleNotFoundError: No module named 'psycopg2' in Python | bobbyhadz
April 8, 2024 - Copied!pip install psycopg2-binary # 👇️ For Python 3 pip3 install psycopg2-binary # 👇️ If you get a permissions error sudo pip3 install psycopg2-binary # 👇️ If you don't have pip in your PATH environment variable python -m pip install psycopg2-binary # 👇️ For Python 3 python3 -m pip install psycopg2-binary # 👇️ Alternative if you get a permissions error pip install psycopg2-binary --user # 👇️ Alternative for macOS brew install postgresql # 👇️ Alternative for Debian (Ubuntu) sudo apt install build-essential libpq-dev python3-dev pip3 install psycopg2 # 👇️ Alternative for Red Hat / CentOS / Fedora sudo yum install python3-devel postgresql-devel pip3 install psycopg2 # 👇️ For Anaconda conda install -c conda-forge psycopg2-binary
🌐
GitHub
github.com › psycopg › psycopg2 › issues › 1282
Error loading psycopg2 module: No module named 'psycopg2' · Issue #1282 · psycopg/psycopg2
May 26, 2021 - (env) PS D:\Users\llagos.NB-KEYONE15\Visual Studio projects\ecommerce-psql> python manage.py makemigrations Traceback (most recent call last): File "D:\Users\llagos.NB-KEYONE15\Visual Studio projects\ecommerce-psql\env\lib\site-packages\django\db\backends\postgresql\base.py", line 25, in import psycopg2 as Database ModuleNotFoundError: No module named 'psycopg2' ...
Author   psycopg
Find elsewhere
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-error-modulenotfounderror-no-module-named-psycopg2
How to Resolve "ModuleNotFoundError: No module named 'psycopg2'" in Python | Tutorial Reference
The ModuleNotFoundError: No module named 'psycopg2' is a common Python error indicating that the interpreter can not find the psycopg2 library, which is the most popular PostgreSQL database adapter for Python. This usually means the necessary package hasn't been installed correctly in the active ...
🌐
Reddit
reddit.com › r/postgresql › pip3 install pyscopg2 but library import error despite pip insta
r/PostgreSQL on Reddit: pip3 install pyscopg2 but library import error despite pip insta
January 18, 2023 -

MacOs M1, Python3 and postgresSQL.

I did

  pip3 install psycopg2-binary 

then

import psycopg2 

but I get this error

File "/Users/lce21/Documents/GitHub/hazen-web-app/hazen-web-app/lib/python3.8/site- packages/psycopg2/__init__.py", line 51, in <module> from psycopg2._psycopg import ( # noqa ImportError: dlopen(/Users/lce21/Documents/GitHub/hazen-web-app/hazen-web- app/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so, 0x0002): Library not loaded: /usr/local/opt/postgresql/lib/libpq.5.dylib Referenced from: /Users/lce21/Documents/GitHub/hazen-web-app/hazen-web- app/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so Reason: tried: '/usr/local/opt/postgresql/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such. file), '/usr/local/Cellar/postgresql@14/14.6_1/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file)

I read I need to change file locations but I am a real newbie and I don't understand how to do that

🌐
Python Pool
pythonpool.com › home › blog › [solved] importerror: no module named ‘psycopg2’
[Solved] ImportError: No Module Named 'psycopg2' - Python Pool
May 6, 2022 - Many "No module named psycopg2" errors occur due to working on incorrect virtual environments and installing the 'psycopg2' on a totally...
🌐
Itsourcecode
itsourcecode.com › home › modulenotfounderror: no module named psycopg2
Modulenotfounderror: no module named psycopg2 [SOLVED]
April 26, 2023 - Resolving the error modulenotfounderror: no module named psycopg2 is an easy task. All you have to do is install the psycopg2-binary module. But before that, verify if you have pip installed on your system; if not, install it.
🌐
Stack Overflow
stackoverflow.com › questions › 72119534 › modulenotfounderror-no-module-named-psycopg2-extras › 72120104
python - ModuleNotFoundError: No module named 'psycopg2.extras' - Stack Overflow
4 ImportError: No module named 'psycopg2' 111 Can't install psycopg2 package through pip install on MacOS · 2 Cannot get psycopg2 to work, but installed correctly. Mac OS · 6 ModuleNotFoundError: No module named 'psycopg2' 2 ModuleNotFoundError: No module named 'psycopg2' (python3, mac, pip3 shows psycopg2 successfully installed) 0 Psycopg2 is not importing in MacOS ·
🌐
Finxter
blog.finxter.com › fixed-modulenotfounderror-no-module-named-psycopg2-binary
[Fixed] ModuleNotFoundError: No module named ‘psycopg2-binary’ – Be on the Right Side of Change
June 12, 2022 - Step 4: Now install the library using pip install psycopg2-binary command. Here’s an analogous example: After having followed the above steps, execute our script once again. And you should get the desired output. The ModuleNotFoundError may appear due to relative imports.
🌐
Reddit
reddit.com › r/django › why am i getting 'modulenotfounderror' after installing psycopg2 and running 'python manage.py migrate' in my django project?
Why am I getting 'ModuleNotFoundError' after installing psycopg2 and running 'python manage.py migrate' in my Django project? : r/django
November 25, 2024 - I think the package name was exactly `psycopg`, I'll check the project dependencies and edit the comment if it's wrong. ... I had something similar recently, and I needed libpq, which I installed with Homebrew: https://stackoverflow.com/questions/44654216/correct-way-to-install-psql-without-full-postgres-on-macos ... Why don’t you post the whole error traceback? It tells you which module was not found and why.
🌐
Reddit
reddit.com › r/django › problem with psycopg2
r/django on Reddit: Problem with psycopg2
July 16, 2024 -

Here I am trying to connect my PostgreSQL db. I can see them install whenever I run pip freeze. Despite trying many fixes I get the following error when I type in py manage.py makemigrations. I have attempted many solutions online but none seem to work. Please help me out geeks stuck here for 2 days!!

ERROR :

Traceback (most recent call last):

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\postgresql\base.py", line 25, in <module>

import psycopg as Database

ModuleNotFoundError: No module named 'psycopg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\postgresql\base.py", line 27, in <module>

import psycopg2 as Database

ModuleNotFoundError: No module named 'psycopg2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "F:\GymManagement\gymManageSys\manage.py", line 22, in <module>

main()

File "F:\GymManagement\gymManageSys\manage.py", line 18, in main

execute_from_command_line(sys.argv)

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line

utility.execute()

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\__init__.py", line 416, in execute

django.setup()

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\__init__.py", line 24, in setup

apps.populate(settings.INSTALLED_APPS)

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\apps\registry.py", line 116, in populate

app_config.import_models()

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\apps\config.py", line 269, in import_models

self.models_module = import_module(models_module_name)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "<frozen importlib._bootstrap>", line 1387, in _gcd_import

File "<frozen importlib._bootstrap>", line 1360, in _find_and_load

File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked

File "<frozen importlib._bootstrap>", line 935, in _load_unlocked

File "<frozen importlib._bootstrap_external>", line 995, in exec_module

File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\auth\models.py", line 3, in <module>

from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\auth\base_user.py", line 59, in <module>

class AbstractBaseUser(models.Model):

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\base.py", line 143, in __new__

new_class.add_to_class("_meta", Options(meta, app_label))

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\base.py", line 371, in add_to_class

value.contribute_to_class(cls, name)

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\options.py", line 243, in contribute_to_class

self.db_table, connection.ops.max_name_length()

^^^^^^^^^^^^^^

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\connection.py", line 15, in __getattr__

return getattr(self._connections[self._alias], item)

~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\connection.py", line 62, in __getitem__

conn = self.create_connection(alias)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\utils.py", line 193, in create_connection

backend = load_backend(db["ENGINE"])

^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\utils.py", line 113, in load_backend

return import_module("%s.base" % backend_name)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\Neel\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\postgresql\base.py", line 29, in <module>

raise ImproperlyConfigured("Error loading psycopg2 or psycopg module")

django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 or psycopg module