PostgreSQL Download Mac OS

Hello, I’ve downloaded both postgreSQL and psycopg2 from the links within the lesson, but I can only import psycopg2 in anacondas jupyter notebooks. I cannot import the psycopg2 module in IDLE or ATOM without getting the “Reason: image not found” error. I can also use the terminal through the PostgreSQL application to run queries, but I can’t import the psycopg2 module in any editor/IDE’s other than Jupyter Notebooks. If anyone has recently tried this on MacOS and came across the same problem, can you give me a solution?

HI @tyrantula767: I have not attempted this but I would like to ask: did you install the packages via Anaconda Prompt/Terminal? If so you may need to install it using pip3 instead, since Anaconda and the local environment use differing package managers and thus you may be getting errors when importing packages locally.

Hope this helps!

I’ve just tried using pip3 to install psycopg2. I’ve been using the bash terminal to download packages. Whenever I use pip3, I get “Could not find a version that satisfies the requirement psycopg2 (from versions: )
No matching distribution found for psycopg2
You are using pip version 19.0.3, however version 20.2b1 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.” When I use the current pip install psycopg2, I get :
“Requirement already satisfied: psycopg2 in /anaconda3/lib/python3.7/site-packages (2.8.5).” Did it download to the wrong place? Thanks.

Hi @tyrantula767: try entering this into bash
python -c "import psycopg2"

Hope this helps!

Hey. I’ve tried to enter it into the bash terminal. Whenever I do, there isn’t any error and the regular prompt appears. Whenever I activate the interactive shell within bash terminal or IDLE and enter the line I get :
“File “”, line 1
python -c “import psycopg2”
^
SyntaxError: invalid syntax.”
I get the same error when I enter it as python -c “import psycopg2”, python3 -c “import psycopg2”, python -c import psycopg2, or python3 -c import psycopg2. It’s not just psycopg2, numpy, pandas, & any other packages that I’ve previously installed only works in Jupyter. Maybe I might have accidentally configured it to download packages into anacondas whenever I first installed anacondas. If this is true, is there any way to change it so that I can import packages in all editors/IDEs? Thanks.

I just installed Postgres on mac and I have exactly the same issue.
I’ve tried the same steps you applied, resulting in the same output/error.
Also, I do have an anaconda distribution running.

Could the issue be orginating from the instruction in the mission to first install psycopg2 using anaconda?

@Sahil could you help look into this matter? Thanks.

1 Like

Hi @tyrantula767, @tyrantula767,

Can you please try installing the psycopg2-binary instead of psycopg2

pip3 install psycopg2-binary

After that you should be able to import psycopg2 without any problem. Let me know how that goes.

Best,
Sahil

Thanks a lot @Sahil, this worked like a charm! It now works in bash terminal / IDLE.

2 Likes