How to set env variable in Jupyter notebook

前端 未结 8 878
时光取名叫无心
时光取名叫无心 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:22

    A gotcha I ran into: The following two commands are equivalent. Note the first cannot use quotes. Somewhat counterintuitively, quoting the string when using %env VAR ... will result in the quotes being included as part of the variable's value, which is probably not what you want.

    %env MYPATH=C:/Folder Name/file.txt
    

    and

    import os
    os.environ['MYPATH'] = "C:/Folder Name/file.txt"
    

提交回复
热议问题