[英]Jupyter note book ModuleNotFoundError: No module named 'psycopg2' while Requirement already satisfied
I worked this issue for 2 days: when I import psycopg2 into jupter notebook,it always return:我处理这个问题 2 天:当我将 psycopg2 导入 jupter notebook 时,它总是返回:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-7d2da0a5d979> in <module>
----> 1 import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
I have used all the way no matter pip or conda to install both psycopg2 and psycopg2-binary but none of them works for me.无论 pip 还是 conda,我都一直使用它来安装 psycopg2 和 psycopg2-binary,但它们都不适合我。
I'm using MAC and python version in anaconda is python 3.9我在anaconda中使用MAC和python版本是python 3.9
Any one can help?任何人都可以帮忙吗?
I tried to reproduce your problem (albeit on Linux) but everything worked flawlessly.我试图重现您的问题(尽管是在 Linux 上),但一切都完美无缺。
Because your workflow for creating and using the Jupyter Notebook is not super-clear, it might be a good idea to run the code that worked for me and see whether it helps:因为您创建和使用 Jupyter Notebook 的工作流程不是很清楚,所以运行对我有用的代码并查看它是否有帮助可能是个好主意:
# Install packages from conda-forge (usually the best choice and very up-to-date packages)
conda create --name test python=3.9 jupyterlab psycopg2 -c conda-forge
# activate the new environment
conda activate test
# Start Jupyterlab
jupyter-lab
After testing you can remove the environment like so测试后,您可以像这样删除环境
conda deactivate
conda env remove --name test
Let me know whether it helped:-)让我知道它是否有帮助:-)
first, u have to download the library.首先,你必须下载库。 using this command in juypter notebook.
在 juypter 笔记本中使用此命令。 --> conda install psycopg2 make sure you have an inte.net connection then u have to wait for 1-2 min it automatically downloads the library.
--> conda install psycopg2 确保你有一个 inte.net 连接然后你必须等待 1-2 分钟它会自动下载库。 then u can use that
那么你可以使用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.