chrishicks
chrishicks

Reputation: 103

ImportError when importing psycopg2 on M1

Has anyone gotten this error when importing psycopg2 after successful installation?

ImportError: dlopen(/Users/chrishicks/Desktop/test/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 0x0002):
tried: '/Users/chrishicks/Desktop/test/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so'
(mach-o file, but is an incompatible architecture
(have 'x86_64', need 'arm64e')),
'/usr/local/lib/_psycopg.cpython-39-darwin.so' (no such file),
'/usr/lib/_psycopg.cpython-39-darwin.so' (no such file)

I have tried installing psycopg2 and psycopg2-binary and have tried both while running iTerm in Rosetta.

Upvotes: 10

Views: 8802

Answers (2)

Lane
Lane

Reputation: 4996

my fellow had the same issue. I consoled pip3.9 install psycopg2-binary --force-reinstall --no-cache-dir but it didn't work for him. I helped him to solved it by this way: firstly, uninstall the psycopg2-binary

pip uninstall psycopg2-binary

Then, install it

pip install psycopg2-binary

@hardy

Upvotes: 2

samrizz4
samrizz4

Reputation: 586

Using this line should fix it:

pip3.9 install psycopg2-binary --force-reinstall --no-cache-dir

Upvotes: 35

Related Questions