I have import psycopg2 in my code yet I keep getting ImportError: No module named psycopg2when I try to run it. I've tried

└─$ pip3 install psycopg2 
└─$ pip install psycopg2-binary  
└─$ sudo apt-get install build-dep python-psycopg2

anyone have a solution to this?
The issue here is: Which Python version do you want to have psycopg2? I am posting 2 solutions, since I'm not sure which one is helpful in your case:

If you want to install it for Python 2, python -m pip install psycopg2 should do this.

If you want to install the package for Python 3, you can run python3 -m pip or pip3. This should avoid confusions with Python 2 installations.
Issues with psycopg2