sys.path different in Jupyter and Python - how to import own modules in Jupyter?

ulf picture ulf · Jan 24, 2016 · Viewed 94.5k times · Source

In Jupyter my own little module is not loaded but in python/bpython is everything is fine. When typing

import sys
print(sys.path)

the path to my module will not in show in Jupyter but in python/bpython it is still there.

I am using:

  1. PYTHONPATH in .bashrc to include my module,
  2. Jupyter and bpython inside a virtualenv.

The most similar questions is this Cannot import modules in jupyter notebook; wrong sys.path

How to configure Jupyter to load my modules automagically?

Answer

Dogan Askan picture Dogan Askan · Mar 10, 2017

Here is what I do on my projects in jupyter notebook,

import sys
sys.path.append("../") # go to parent dir
from customFunctions import *

Then, to affect changes in customFunctions.py,

%load_ext autoreload
%autoreload 2