简体   繁体   English

无法将情节导入 Jupyter Notebook

[英]Unable to import plotly into Jupyter Notebook

我是 Python 的新手,我使用命令pip install plotly使用 Anaconda 提示符安装了 plotly 库,它显示它安装在已安装的库下,但当我尝试通过 Jupyter 库导入时没有被导入,说找不到模块。

This is typically due to multiple Python interpreters being installed, so the Python you see in the notebook is probably not the Python you used to install plotly.这通常是由于安装了多个 Python 解释器,所以您在 notebook 中看到的 Python 可能不是您用来安装的 Python。

You can check this by looking at sys.executable and sys.path , and comparing those with where pip in the Anaconda prompt where you ran pip install plotly .您可以通过查看检查这个sys.executablesys.path ,并比较那些where pip在巨蟒提示,你跑了pip install plotly

You can make sure to use the right Python by doing:您可以通过执行以下操作来确保使用正确的 Python:

C:\full\path\to\right\python.exe -m pip install plotly

This should be the same as sys.executable in your notebook.这应该与笔记本中的sys.executable相同。

I had the similar issue.我有类似的问题。 Go to Anaconda prompt and type pip install plotly hit enter.转到 Anaconda 提示符并输入pip install plotly点击回车。 Restart the kernel and try importing it again.重新启动内核并再次尝试导入。

Going further feom @minrk answer:进一步 feom @minrk 回答:

After a while searching about this problem, I discovered it is a broken conda-kernel trough jupyter notebook issue.搜索了一段时间后,我发现这是一个损坏的 conda-kernel 槽 jupyter notebook 问题。

Inside your notebook check if it is pointing to the write python executable's envinronment path by using minrk solution:在您的笔记本中,使用 minrk 解决方案检查它是否指向 write python 可执行文件的环境路径

import sys
sys.executable 

# >>>> 'C:\\Users\\username\\AppData\\Local\\Continuum\\anaconda3\\envs\\**wrong_env**\\python.exe'

If it isn't , the simple solution is to install nb_conda :如果不是,简单的解决方案是install nb_conda

conda install nb_conda

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM