在 M1 上导入 psycopg2 时出现导入错误
有人在成功安装后导入 psycopg2 时遇到此错误吗?
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)
我尝试安装 psycopg2 和 psycopg2-binary 并在 Rosetta 中运行 iTerm 时尝试了这两种方法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用这一行应该可以修复它:
Using this line should fix it:
我的同伴也有同样的问题。
我安慰了
pip3.9 install psycopg2-binary --force-reinstall --no-cache-dir
但这对他不起作用。我帮他解决了这个问题:
首先,卸载
psycopg2-binary
然后,安装它
@hardy
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
Then, install it
@hardy