Skip to content
Advertisement

jupyter notebook can’t detect conda kernels only on boot

I’m trying to automatically start jupyter server on boot. (ec2, amazon linux)

I got the jupyter server working and correctly loading all the conda kernels.

and I tried to run jupyter on boot. (tried rc.local, systemd, crontab and all fails to load conda kernels and only loads basic python2 and python3 kernels)

I’ve traced it down to the nb_conda_kernels not finding being able to call ‘conda’ on boot, as below:

JavaScript

The weirdest thing is that when I kill the running server with “sudo ss –tulpn | grep 8888” (to find pid for jupyter notebook which is listening on port 8888) and “sudo kill -9 {pid}” (to kill the process. checked that I killed it successfully), and I restart the server via the same command used in boot, then jupyter successfully loads the conda kernels, as below:

JavaScript

I’ve seen one particular question on stackoverflow about this issue. (Jupyter notebook can’t find kernel when run through /etc/rc.local) but the issue here is that when I type “jupyter kernelspec list”, I only get python3 and python2, even when jupyter has already loaded conda kernels successfully.

JavaScript

Also, I’ve tried changing environmentspecmanager in jupyter config file to see if it solves the issue but it didn’t. (same error log, “couldn’t call conda”)

what is the problem here?

Advertisement

Answer

conda has not been configured yet when rc.local is executed. This is usually done through the .bashrc file. But you can try to just add it to the rc.local script (before launching jupyter):

JavaScript

This should set up the use of conda

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement