$PYTHONPATH for jupyter notebook (and jupyter notebook within jupyter lab)

16,055 views
Skip to first unread message

Eric Gayer

unread,
Mar 27, 2018, 4:57:45 PM3/27/18
to Project Jupyter
Hi guys, 

I am struggling to understand how to permanently set the path to my own modules directory for any jupyter notebook (and/or any jupyter notebook in jupyter lab).

In spyder, the PYTHONPATH manager helps adding paths pointing  modules.
Using jupyter notebook, all I found is to add this piece of code each time we start/create a notebook

import sys
sys.path.append("path to my modules dir")
import mymodule as mm
How to permanently add a path to modules so every new jupyter notebook understand it ?

Thanks for your help
Eric

Paul Hobson

unread,
Mar 27, 2018, 6:00:30 PM3/27/18
to jup...@googlegroups.com
You could include this in a startup script.
https://stackoverflow.com/questions/32211109/automate-standard-jupyter-ipython-notebook-imports

But I don't think you should do this. It'd be more transparent and transferable (e.g., if you had to email a notebook to a colleague) to create a setup.py file for your module and install it as a proper library.
-paul

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/61736ec5-4306-4199-9831-3ed8fc474ea1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roland Weber

unread,
Mar 28, 2018, 1:24:50 AM3/28/18
to Project Jupyter
You can add environment variables to the kernelspecs.

Eric Gayer

unread,
Apr 4, 2018, 3:31:11 AM4/4/18
to Project Jupyter
thank you guys for your answers, however with my rather low "technical skills" I am still doubtful on the easiness of how to do it properly...

would it be possible to point me to a documentation that explains kernelspecs ?
thanks
Eric

Thomas Kluyver

unread,
Apr 4, 2018, 5:29:42 AM4/4/18
to Project Jupyter
On 4 April 2018 at 09:31, Eric Gayer <ega...@gmail.com> wrote:
would it be possible to point me to a documentation that explains kernelspecs ?

Reply all
Reply to author
Forward
0 new messages