在 M1 上导入 psycopg2 时出现导入错误

发布于 2025-01-16 07:06:50 字数 579 浏览 2 评论 0原文

有人在成功安装后导入 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伪心 2025-01-23 07:06:50

使用这一行应该可以修复它:

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

Using this line should fix it:

pip3.9 install psycopg2-binary --force-reinstall --no-cache-dir
可是我不能没有你 2025-01-23 07:06:50

我的同伴也有同样的问题。
我安慰了 pip3.9 install psycopg2-binary --force-reinstall --no-cache-dir 但这对他不起作用。
我帮他解决了这个问题:
首先,卸载psycopg2-binary

pip uninstall psycopg2-binary

然后,安装它

pip install 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

pip uninstall psycopg2-binary

Then, install it

pip install psycopg2-binary

@hardy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文