Start Jupyter Notebook at Boot Raspbian/BerryConda3

Good morning!

I have installed raspbian and berryconda  on a pi3.

I'm failing miserably at getting the jupyter notebook server to run at boot.

Here is some info that might help:
Here is the bottom of my rc.local:
# --------------------------------------------------------------------
# My Configuration
#---------------------------------------------------------------------
# Start Jupyter Server at boot
/home/pi/berryconda3/bin/jupyter-notebook
exit 0

Here is what I get when I type "which jupyter":
/home/pi/berryconda3/bin/jupyter

Here's my path:
/home/pi/berryconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games

And finally if I type "jupyter-notebook" from an ssh session as user pi - it starts the jupyter notebook server w/o issue

Thanks in advance for any help.  This is driving me nutz!  :D
LVL 1
ttist25Asked:
Who is Participating?
 
gelonidaCommented:
Normally you do not want to add blocking or interactive programs
into /etc/rc.local.

This is intended for services, that start in the background and have no user interaction.

Please correct me if I'm wrong, but I think jupyter-notebook is an interactive application for ipython notebooks.


What exactly do you try to achieve?


Do you want to switch on your pi and automatically have a notebook started.

Do you want to have this notebook in a console session or in an Xwindows session.


Perhaps following could work for your use case.

You configure your raspberry to automatically start in graphical mode and to auto logon.

Then there should be a way to autostart an application (start a session) with the active desktop manager.

Please note that in order to run  jupyter-notebook (if it is really a console application), then you have to first start a terminal and then start the notebook in this console.

starting a terminal with a given command should be something liek

 xterm -e jupyter-notebook & # assuming xterm is installed on your pi

If you want to use another terminal application, then check the manpage of your prefered  terminal program to see how to create a terminal and start a certain application


I never autostarted an application on a pi, but following might work if you autologin / autostart in graphical mode and if you desktop is LXDE Desktop


just add the end of the file /etc/xdg/lxsession/LXDE-pi/autostart

something like
@ xterm -e jupyter-notebook

taken from

https://www.raspberrypi-spy.co.uk/2014/05/how-to-autostart-apps-in-rasbian-lxde-desktop/
0
 
ttist25Author Commented:
Thanks for the response gelonida and sorry for the delay in my response.  

The jupyer notebook command actually starts a "notebook server" that can then be accessed from a web browser.  My goal was to have a headless PI sitting over on the shelf that I could access from any computer on my network.  I thought it would be a great use of a PI3 that was sitting in my desk drawer doing nothing (it remains to be seen whether it's actually good in practice :D).  

Anyway, I managed to get this working after talking to my son.  Here is his solution:
1.  Create a script "/home/pi/startup.sh" with the following lines:
# shell script to set path and run jupyter notebook server at boot
export PATH="$PATH:/home/pi/berryconda3/bin/"
jupyter notebook

Open in new window


2.  Add the following to /etc/rc.local right above exit 0:
# Start Jupyter Notebook Server at boot
su pi -c 'bash /home/pi/startup.sh'

Open in new window

So far this seems to be working great.  If the power goes out, no worries, the notebook server starts up all on its own and I can browse to the PI and access the notebooks I've created.  Again, thanks for the help!
0
 
gelonidaCommented:
Yep using su to start a process as another user is the right thing to do. Creating an intermediate script in order to keep /etc/rc.local is also a good idea.

Well if you ever want to autostart an application on a pi with a screen and desktop you have some pointers.

Happy notebooking.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.