0

EDIT: This is not solved in the suggested duplicate; reloading the module after editing the file doesn't help.

I have a python file "/home/Misc/misc_def.py" collecting some functions that I'm using in several ipython notebooks. The first cell in each notebook is

import csv
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
%matplotlib inline
sns.set_style('white')
from sys import path
path.append('/home/Misc')
import misc_def

However, the strange thing is that sometimes this works (the notebook can find the functions in the file) and sometimes it doesn't. I'm using notebooks in different folders, but I think this shouldn't matter since it's all absolute paths. The errors I get are standard for not finding functions; e.g.

NameError: name 'get_overlap_data' is not defined

Is there something unstable about the way I do it above?

Community
  • 1
  • 1
jorgen
  • 3,425
  • 4
  • 31
  • 53
  • 2
    Are you editing the file with the functions at the same time as the notebook? – Sinkingpoint Oct 21 '15 at 08:19
  • I was; however I would save the function file before trying to use it. I now tried to close it completely before importing it, with the same result. – jorgen Oct 21 '15 at 08:23
  • Possible duplicate of [Autoreload of modules in IPython](http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython) – Mel Oct 21 '15 at 08:32
  • @tmoreau reloading after changing the file does not help – jorgen Oct 21 '15 at 08:40

0 Answers0