Plotly in Jupyter issue

33,340

Solution 1

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.

Solution 2

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.

Solution 3

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

Solution 4

Using plotly.plotly creates errors with different versions of python.

  1. ensure you don't have multiple version of python installed and in your environment variables path.

  2. Try from now to work with 'chart-studio'.

Run

 'pip install chart-studio'

and then import using:

 'import chart_studio.plotly as py'

Solution 5

`pip install plotly. this problem usually occurs on cloud anaconda navigator when you need to plot a Plotly graph in a python program here is the solution.I suggest simply run these commands on window prompt or on git bash

Share:
33,340
Admin
Author by

Admin

Updated on October 12, 2021

Comments

  • Admin
    Admin over 2 years

    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)

  • hjmnzs
    hjmnzs over 6 years
    It didn't worked. In terminal if I call python3; import plotly , it's ok but not in Jupyter notebook.
  • MyNameIsCaleb
    MyNameIsCaleb over 4 years
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
  • sh_07
    sh_07 over 4 years
    @MyNameIsCaleb thank you for ur feedback, i have updated it accordingly. Ill be more careful with my future answers :) have a nice day ahead.
  • merv
    merv over 4 years
    That package is for an extension that provides a GUI for managing Conda envs in Jupyter. This likely ended up installing jupyter in your Conda env, which, while perhaps sufficient, is unnecessary and an improper way to solve a misconfigured Jupyter setup.
  • mrbTT
    mrbTT over 4 years
    How so improper if it fixes misconfigured settings? I've stated that it solved to me as an aditional way of solving if others find the other answers insuficient. All you've said is your opinion.
  • merv
    merv over 4 years
    But it doesn't "fix misconfigured settings", i.e., the disconnect between your existing Jupyter installation and the env you want to use - it instead creates an entirely new installation of Jupyter. Proposing nb_conda is also misleading as to the underlying problems (not having configured your env to work in Jupyter - see this thread) and suggests that installing an unnecessary component somehow fixes things.
  • mrbTT
    mrbTT over 4 years
    Again, it fixed for me and it might fix for someone else which problem is not as complex as OP's, wether you think is a solution or not. I'm just leaving it here in case someone is trying to fix and nothing works. The above might.
  • mrbTT
    mrbTT over 4 years
  • JacoSolari
    JacoSolari over 3 years
    Welcome to SO!It is very useful if you add the error message (with proper formatting) to your question. I would suggest you edit your question with the exact error you are getting so people can help you better and faster.