0

I tried:

pip3 install psycopg2, pip install psycopg2,

Requirement already satisfied: psycopg2 in
c:\users\dzitc\appdata\local\programs\python\python37-32\lib\site-packages (2.8.3)

In test.py I imported the psycopg2 by:

import psycopg2

When debugging the test.py I get results as :

Exception has occurred: ModuleNotFoundError No module named 'psycopg2'
File "C:\Users\DzITC\Desktop\PYFiles\Main.py", line 7, in <module> import psycopg2
2
  • 1
    Are you sure, you have psycopg2 imported everywhere you need it ? The error is about Main.py ! Commented Aug 30, 2019 at 12:51
  • I was having this issue last night on my Mac! Commented Aug 30, 2019 at 14:53

2 Answers 2

1

I fixed it by changing the Python IDE interpreter.

Sign up to request clarification or add additional context in comments.

Comments

0

Try with:

python -m pip install psycopg2-binary

as that would install psycopg2 for your system Python.

Try to run your script with:

python path_to_script\test.py

I guess you're trying to run test.py some other way, like double-click and maybe you've associated .py files to some other Python executable.

2 Comments

Why not psycopg2-binary ?
Requirement already satisfied: psycopg2-binary in c:\users\dzitc\appdata\local\programs\python\python37-32\lib\site-packages (2.8.3)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.