How to set env variable in Jupyter notebook

前端 未结 8 817
时光取名叫无心
时光取名叫无心 2020-11-27 13:05

I\'ve a problem that Jupyter can\'t see env variable in bashrc file, is there a way to load these variables in jupyter or add custome variable to it?

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 13:08

    You can setup environment variables in your code as follows:

    import sys,os,os.path
    sys.path.append(os.path.expanduser('~/code/eol_hsrl_python'))
    os.environ['HSRL_INSTRUMENT']='gvhsrl'
    os.environ['HSRL_CONFIG']=os.path.expanduser('~/hsrl_config')
    

    This if of course a temporary fix, to get a permanent one, you probably need to export the variables into your ~.profile, more information can be found here

提交回复
热议问题