本文介绍了如何在Jupyter Notebook中设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题,Jupyter在bashrc文件中看不到env变量,有没有办法在jupyter中加载这些变量或向其中添加自定义变量?
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?
推荐答案
要在jupyter笔记本中设置环境变量,只需使用%
魔术命令,例如%env
或%set_env
,例如%env MY_VAR=MY_VALUE
或%env MY_VAR MY_VALUE
. (单独使用%env
可以打印出当前的环境变量.)
To set an env variable in a jupyter notebook, just use a %
magic commands, either %env
or %set_env
, e.g., %env MY_VAR=MY_VALUE
or %env MY_VAR MY_VALUE
. (Use %env
by itself to print out current environmental variables.)
请参阅: http://ipython.readthedocs.io/en/stable/互动式/magics.html
这篇关于如何在Jupyter Notebook中设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!