Unable to Get Panel Working with Jupyter notebook

Many thanks for your suggestions. I learnt a lot from you.

then I issued conda activate panelenv command no errors!

But then I tried
import panel as pn
It gave me error as module not found!

How do you open Jupyter Notebook?

I go to anaconda and select Jupyter Notebook

You could also try installing panel from the notebook !pip install panel. That might fix the issue. But we will never understand the cause.

Thanks Marc, I just did

Still the same error module not found when I issue import panel as pn command within Jupyter notebook

Hi @Vivek,

May bottle down to a solution but for myself at least when I know something should work but isn’t I uninstall / reinstall from scratch but now I know about vm’s mentioned above that has reduced the amount of effort. I used to find it a hindrance without vms as I was always breaking my base working environment one way or another, now if I break a vm generally I can just spin up a new one and I’m off again. That said I think I’ve also learned some new useful commands from this thread.

As you’ve installed the full anaconda package I don’t know if this will work or not or if it’ll behave differently but try running the notebook or lab from the command prompt directly, what is the result if from the command prompt you run `jupyter notebook’ or ‘jupyter lab’ when it launches into browser can you then import panel? I suspect not because other modules are importing but maybe worth a try

Hi Carl, Thanks for your suggestion. I did just what you recommended but did not work!

You can try the recipes inn this StackOverflow thread. I had some problems with jupyterlab, not with jupyter notebook, but I think it should be similar. I think the situation is jupyter is not seeing your conda environment, and it is running from other place. You need to add the jupyter kernel to the notebook you are running. I am not an expert, but with jupyterlab this recipe works.

As a suggestion, I think it is uncommon to use Anaconda navigator, and the best practice is to use some terminal like Anaconda prompt.

image

If you open the anaconda prompt, and in that case you activate the relevant conda environment with panel installed it usually works.

It’s not so uncommon to use Anaconda Navigator :upside_down_face: Many people start their journey this way, I did too!

But indeed using the Anaconda prompt is a good habit to take.

@Vivek open the prompt as shown above, run conda activate panelenv and jupyter lab. Then open a notebook and try to import Panel.

I did exactly what you recommended, still problem not resolved :frowning:

Have you tried launching Jupyter from the conda prompt?

Do you mean cmd prompt within Anaconda, yes I have. It does not work, same error. I do not know about conda prompt!

What about other packages like Param or Holoviews? If you install those, do they work inside Jupyter?

1 Like

Can you try lower casing Holoviews and Param to import holoviews as hv and import param?

Thanks Marc, good catch! But unfortunately outcome is the same

how are you installing these packages?

I click on CMD.exe within Anaconda and then issuing pin installing the packages. May be I should have used conda install panel. I did try this command at a later stage.

I’m not really familiar with that method. I would try creating a separate conda environment, use mamba to install panel and jupyterlab and then launch jupyterlab from the command line inside that environment.

Hi @Vivek,

I’m just pasting my instructions for getting up and running here, maybe they’ll help you. As I mentioned before if I hit problems I start again so that said back up important work uninstall eveythring, python, anaconda and all and from a blank canvas this is what I do:

#1 I visit miniconda https://docs.conda.io/en/latest/miniconda.html

#2 I install the latest version for my system in this case 64 bit for Windows

#3 I install to defaults

#4 Now I open the Anaconda Powershell Prompt that has been installed with admin rights

#5 In the (base) environment I insall jupyter lab like so

image

#6 now I create a virtual environment, I try to specify a known compatible python version that works with panel, holoviews etc

image

#7 now I enter the virtual environment that I just created so I can setup a few things

image

note that the base has now changed to virtual environment name

image

#9 Now I want to make my virtual environment available to jupyter lab that I just installed so I do the following instructions (the reason I do this step and repeat for each vm is so when I have multiple virtual environments they’re all under the same hood if you like)

image

image

#10 now I want to install panel etc in the virtual environment

image

#11 now I return to the base environment where I launch jupyter lab

image

#12 now when jupyter lab is launched the virtual enviroment that has been setup is available to utilise, now if you launch the vm from within jupyter lab all being well when you import panel you will not get module not found.


image

Alternativelty you can install jupyter lab directly inside the vm, activate the vm and run jupyter lab from there but my preference is the above steps which work for myself.

Hope of some help,

Thanks, Carl.

6 Likes