I need to test a few functions from a code I am building which I import into a jupyter notebook.
issue is, simTools_path is different in the functions and the jupyter notebook. More, when I call these functions from my main python script, it works fine.
MWE
simTools_path/objects/classes.py
simTools_path = os.path.abspath(os.getenv('SIMTOOLS_PATH')) sys.path.append(simTools_path) def testPath(): print 'testPath', simTools_path jupyter notebook
import os,sys # paths simTools_path = os.path.abspath('../') os.environ["SIMTOOLS_PATH"] = "simTools_path" os.environ["PYTHONPATH"] = "simTools_path" sys.path.append(simTools_path) from objects.classes import testPath print simTools_path testPath() results:
simTools_path= /home/jhumberto/WORK/Projects/code/simulations_2016-07-14/simTools testPath= /home/jhumberto/WORK/Projects/code/simulations_2016-07-14/simTools/jupyterNotebooks/simTools_path Notes:
1) I use this path variable in different functions inside different modules to load file data relatively to the simTools_path path.
2) my jupyter notebook is located in /home/jhumberto/WORK/Projects/code/simulations_2016-07-14/simTools/jupyterNotebooks
Any ideas?
os.environ["SIMTOOLS_PATH"] = "simTools_path"supposed to reados.environ["SIMTOOLS_PATH"] = simTools_path(no quote marks)? One points to the parent directory, the other to a folder called simTools_path within the current directory.