can not import module while running project but working in VS Code and local machine.


I am new to start with PyCharm and trying to setup Python venv in my Macbook Pro with M1 chip. But facing an ImportError message while trying to run my project.

ImportError: no pq wrapper available. Attempts made: - couldn't import psycopg 'c' implementation: No module named 'psycopg_c'

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

I have installed all required packages for my project. My PyCharm version is PyCharm 2023.2 (Professional Edition) Build #PY-232.8660.197, built on July 26, 2023.

I have no issue to run my project in VS Code with the same Python interpreter setting. Also there is no issue to run my project in my local Mac from terminal directly. 

I did lots of googling and still not be able to find the solution to fix that ImportError.

Tried the following pip command in venv.

pip install psycopg-binary

pip install psycopg2-binary --force-reinstall --no-cache-dir

pip uninstall psycopg

pip install "psycopg[c]"

pip install "psycopg[binary,pool]"

None of those command working for me.

Can someone point out where is the issue so I can fix it?