Plotly in Jupyter issue

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 08:45:26

问题


I installed plotly.py to work some plots using Jupyter but I cannot import it.

! pip install plotly --upgrade
Requirement already up-to-date: plotly in c:\python34\lib\site-packages
Requirement already up-to-date: requests in c:\python34\lib\site-packages (from plotly)
Requirement already up-to-date: six in c:\python34\lib\site-packages (from plotly)
Requirement already up-to-date: pytz in c:\python34\lib\site-packages (from plotly)
Cleaning up...

and then

  import plotly
  ---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-6-c27a4132ad2e> in <module>()
----> 1 import plotly

  ImportError: No module named 'plotly'

I'm running Python 3.4.1, so as Jupyter, and the thing that I cannot get is that plotly works just fine when I'm running Python from the command line. Any suggestions? (I really don't want to clean install Python)


回答1:


I had the same issues. Running following on command prompt solved my issue.

conda install -c https://conda.anaconda.org/plotly plotly

It is likely that the plotly installed via pip install is somehow not detected by Jupter.




回答2:


I had the same issue. I was scrolling through and found another question about it. I found the solution by going through the directories. pip install is installing in default python lib folder, a more in-depth answer is here.

https://stackoverflow.com/a/48774224/9176740




回答3:


In the jupyter notebook, running the correct kernel you want the package to be installed, run

import sys
!conda install --yes --prefix {sys.prefix} plotly

This installs plotly within the correct kernel.




回答4:


To import seaborn, sklearn and plotly on jupyter notebook first run this on terminal for python "pip install ipykernel", for anaconda "conda install ipykernel" or "python -m ipykernel install"




回答5:


I too have same issue, but it was solved in anaconda prompt by conda install plotly




回答6:


After a while searching about this problem, I discovered it is a broken conda-kernel trough jupyter notebook.

Inside your notebook check if it is pointing to the write python executable's envinronment path by:

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:

conda install nb_conda


来源:https://stackoverflow.com/questions/36959782/plotly-in-jupyter-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!