anaconda prompt可以import,但jupyter notebook import失败的解决办法

首先在终端和jupyter里import sys,然后做下面的事情,看二者的结果是不是不一样。

摘自此链接:

Usually that indicates that the notebook is running with a different Python or in a different environment from Python in the command prompt. Check sys.executable to see which Python it's running in, and sys.path to see where it's looking for imports.

不一样的话按下面做的尝试:

1. 有时候是因为没有在环境中安装jupyter,单独安装一下:

conda install jupyter

或者

pip install jupyter

2. 有时候是jupyter还在原来的旧环境中运行,可以安装nb_conda_kernels包,就可以选择在哪个环境下运行。安装及使用参考这篇文章。

3. 看到一篇主题相似的文章,mark一下:

关于在终端能到import模块 而在jupyter notebook无法导入的问题

你可能感兴趣的:(问题解决)