Intel® DevCloud
Help for those needing help starting or connecting to the Intel® DevCloud
1627 Discussions

Notebook does not run selected kernel

Alcorta__Erika_Susan
New Contributor I
4,389 Views

I created a conda environment called "py36" and used the "ipykernel" tool to add it to the Jupyter Kernels. I see it listed in the GUI:

Alcorta__Erika_Susan_0-1602460207707.png

However, even though I selected it, I could not use the packages I installed. For example "seaborn" is one of those packages (see image below). I used the "conda env list" command to see whether the "py36" kernel is used, but the * is next to "base".

Alcorta__Erika_Susan_3-1602460590187.png

 

It seems like the kernel I selected is ignored.

I can also show from the terminal that seaborn is installed in py36 and not base:

Alcorta__Erika_Susan_2-1602460491399.png

Has anyone encountered this behavior before? How do I solve it?

0 Kudos
1 Solution
JananiC_Intel
Moderator
4,215 Views

Hi,


Thanks for the update.


In jupyter notebook,if you use '!' before the command, it will run in a new terminal.Since this command runs in new terminal in the base environment, conda list shows base as the working environment with * symbol.


Hope this answers your question!


View solution in original post

0 Kudos
15 Replies
JananiC_Intel
Moderator
4,381 Views

Hi,

 

Thanks for posting in Intel forums.

 

First check the python path in jupyter notebook by running import sys  sys.executable in the cell.If it shows /glob python then do the following

 

1)Go to /home/{username}/.local/share/jupyter/kernels/{environment name}

2)Open kernel.json file in that folder

3)Replace the python path with your environment python path.

4)After changing the path, run import sys;sys.executable in the cell and check the path.

 

Try this and let us know the updates.

 

 

0 Kudos
Alcorta__Erika_Susan
New Contributor I
4,374 Views

Hello. The results after I followed the steps are in the picture, it did not work. I am printing the "conda env list" command again. The base environment is selected when it should be py36.

 

Alcorta__Erika_Susan_0-1602619837533.png

 

0 Kudos
JananiC_Intel
Moderator
4,363 Views

Hi,


Did you restart the kernel in jupyter notebook after editing the kernel.json file? It might work if you restart the kernel multiple times.


Thanks.


0 Kudos
Alcorta__Erika_Susan
New Contributor I
4,341 Views

Yes I did restart the kernel, I even created a new notebook. What I see is that after a few seconds the kernel name on the top right corner of Jupyter turns to No Kernel!

Alcorta__Erika_Susan_1-1603228746145.png

A few seconds later (or click on run):

Alcorta__Erika_Susan_2-1603228799947.png

 

As a workaround, I ended up using "pip" with the "--user" flag to install what I need on the base conda environment. However, I still wish I could use multiple conda environments

0 Kudos
JananiC_Intel
Moderator
4,346 Views

Hi,


Did that work? Do you have any update?


0 Kudos
JananiC_Intel
Moderator
4,333 Views

Hi,


Thanks for the update.


Try to remove your kenel with jupyter kernelspec remove <kernel_name> command and add kernel again with ipython kernel install --name "env_name" --user command.We faced similar issue and we were able to solve the issue with the above step.


Kindly try out the above steps and let us know the updates.


0 Kudos
Alcorta__Erika_Susan
New Contributor I
4,322 Views

Hello,

I have removed the kernel, but I do not have permission to run the command you have given to install again:

(base) u45638@s001-n001:~$ ipython kernel install --name py36
[Errno 13] Permission denied: '/usr/local/share/jupyter'

The first time, I used the --user flag. I used it this time as well and I encounter the same issue: when I list the conda environments, "base" is selected instead of "py36":

Alcorta__Erika_Susan_0-1603388255610.png

I activated py36 on the terminal, and you can see I have a version of "seaborn" installed, which was not shown in the second cell of the above notebook.

Alcorta__Erika_Susan_1-1603388334507.png

 

 

0 Kudos
JananiC_Intel
Moderator
4,313 Views

Hi,


You get this"[Errno 13] Permission denied: '/usr/local/share/jupyter'" because you are trying to install in base environment.Try after deactivating the base environment ,you will be able to run,like below.


(base) uxxxxx@s001-n017:~$ ipython kernel install --name py36

[Errno 13] Permission denied: '/usr/local/share/jupyter'

(base) uxxxxx@s001-n017:~$ conda deactivate

uxxxxx@s001-n017:~$ ipython kernel install --name py36

[Errno 13] Permission denied: '/usr/local/share/jupyter'

uxxxxx@s001-n017:~$ ipython kernel install --name py36 --user

Installed kernelspec py36 in /home/uxxxxx/.local/share/jupyter/kernels/py36


Hope this answers your query!


0 Kudos
Alcorta__Erika_Susan
New Contributor I
4,297 Views

Thank you, but I was not able to reinstall yet because ipython module is not installed in the system:

(base) u45638@s001-n057:~$ conda deactivate
u45638@s001-n057:~$ ipython kernel install --name py36 --user

Command 'ipython' not found, but can be installed with:

apt install ipython
Please ask your administrator.

u45638@s001-n057:~$ which python
/usr/bin/python

How should I proceed?

0 Kudos
JananiC_Intel
Moderator
4,282 Views

Hi,


Thanks for the update.


The issue may be due to python path.So you can try any of the below steps.

1)Try to source oneapi environment with source setvars.sh command.After sourcing,your python path will be "/glob/development-tools/versions/oneapi/beta10/inteloneapi/intelpython/latest/bin/python".You can check that with "which python" command.After this you can proceed with "ipython kernel install --name py36 --user" command.

2)You can also solve this issue by exporting the python path like below.

uxxxxx@s001-n022:~$ which python

/usr/bin/python

uxxxxx@s001-n022:~$ export PATH=/glob/intel-python/python3/bin:$PATH

uxxxxx@s001-n022:~$ which python

/glob/intel-python/python3/bin/python

uxxxxx@s001-n022:~$ ipython kernel install --name py36 --user

Installed kernelspec py36 in /home/uxxxxx/.local/share/jupyter/kernels/py36


Hope this helps!



0 Kudos
JananiC_Intel
Moderator
4,265 Views

Hi,


Has the solution provided helped?Please let us know if the issue still persists.



0 Kudos
Alcorta__Erika_Susan
New Contributor I
4,224 Views

Hello,

This time, when I deactivated conda, the global python was set by default and was able to use ipython

Alcorta__Erika_Susan_0-1605120767383.png

However, when I list the conda environments from the jupyter notebook, I still see it picked the "base" one:

Alcorta__Erika_Susan_1-1605120841197.png

 

 

0 Kudos
JananiC_Intel
Moderator
4,216 Views

Hi,


Thanks for the update.


In jupyter notebook,if you use '!' before the command, it will run in a new terminal.Since this command runs in new terminal in the base environment, conda list shows base as the working environment with * symbol.


Hope this answers your question!


0 Kudos
JananiC_Intel
Moderator
4,159 Views

Hi,


Did that help?Could you give us an update?


0 Kudos
JananiC_Intel
Moderator
4,083 Views

Hi,


We are assuming that the solution provided helped and would no longer be monitoring this issue.Please raise a new thread if you have any further issues.


Regards,

Janani Chandran


0 Kudos
Reply