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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.