我需要从我正在构建的代码中测试几个函数,并将其导入jupyter笔记本。在
问题是,simTools_path在函数和jupyter笔记本中是不同的。而且,当我从python主脚本调用这些函数时,它工作得很好。在
MWE
simTools_路径/对象/类.py
simTools_path = os.path.abspath(os.getenv('SIMTOOLS_PATH'))
sys.path.append(simTools_path)
def testPath():
print 'testPath', simTools_path
jupyter笔记本
^{pr2}$结果:
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
注释:
1)我在不同模块内的不同函数中使用此路径变量来加载相对于simTools_path路径的文件数据。在
2)我的jupyter笔记本位于/home/jhumberto/WORK/Projects/code/simulations_2016-07-14/simTools/jupyterNotebooks
有什么想法吗?在
您混淆了变量
simTools_path
和文本字符串"simTools_path"
。要更正此问题,只需按如下方式更改行:相关问题 更多 >
编程相关推荐