[英]ModuleNotFoundError: No module named 'psycopg2' macOS
Each time I run my script, I get this error % python new_monthly_donations.py Traceback (most recent call last): File "/Users/bdohman/Desktop/uway payments/scripts/new_monthly_donations.py", line 2, in <module> import psycopg2 ModuleNotFoundError: No module named 'psycopg2'
每次运行我的脚本时,我都会收到此错误
% python new_monthly_donations.py Traceback (most recent call last): File "/Users/bdohman/Desktop/uway payments/scripts/new_monthly_donations.py", line 2, in <module> import psycopg2 ModuleNotFoundError: No module named 'psycopg2'
I'm new to python, relatively new to development on a mac.我是 python 的新手,对 Mac 开发比较陌生。
I installed python through the dmg.我通过 dmg 安装了 python。 I have python version 3.9.6 I installed psycopg2 by doing
pip3 install psycopg2
and pip3 install psycopg2-binary
我有 python 版本 3.9.6 我通过
pip3 install psycopg2
和pip3 install psycopg2-binary
了 psycopg2
Each time I run my script I get the error above.每次我运行我的脚本时,我都会收到上面的错误。
The script is being run from a folder on my desktop.该脚本是从我桌面上的一个文件夹中运行的。
Here is the info on psycopg2这是关于 psycopg2 的信息
`pip3 show psycopg2-binary `pip3 显示 psycopg2-binary
Name: psycopg2-binary Version: 2.9.5 Summary: psycopg2 - Python-PostgreSQL Database Adapter Home-page: https://psycopg.org/ Author: Federico Di Gregorio Author-email: fog@initd.org License: LGPL with exceptions Location: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages Requires: Required-by:名称:psycopg2-binary 版本:2.9.5 摘要:psycopg2 - Python-PostgreSQL 数据库适配器 主页: https://psycopg.org/作者:Federico Di Gregorio 作者电子邮件:fog@initd.org 许可证:LGPL 有例外位置:/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages 要求:要求:
% pip3 show psycopg2 % pip3 显示 psycopg2
Name: psycopg2 Version: 2.9.5 Summary: psycopg2 - Python-PostgreSQL Database Adapter Home-page: https://psycopg.org/ Author: Federico Di Gregorio Author-email: fog@initd.org License: LGPL with exceptions Location: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages Requires: Required-by: `名称:psycopg2 版本:2.9.5 摘要:psycopg2 - Python-PostgreSQL 数据库适配器 主页: https://psycopg.org/作者:Federico Di Gregorio 作者-电子邮件:fog@initd.org 许可证:LGPL 有例外 位置: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages 要求:要求:`
I also followed the other steps here > https://rogulski.it/blog/install-psycopg2-on-apple-m1/我还按照此处的其他步骤 > https://rogulski.it/blog/install-psycopg2-on-apple-m1/
I installed pyscopg2 pyscopg2-binary on my mac using pip3 and I expected my script to not through the module not found error.我使用 pip3 在我的 mac 上安装了 pyscopg2 pyscopg2-binary,我希望我的脚本不会通过模块未找到错误。
the fix here was to do python3 filename.py.这里的修复是执行 python3 filename.py。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.