如何在 Jupyter notebook 中设置环境变量 [英] How to set env variable in Jupyter notebook
本文介绍了如何在 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 notebook 中设置 env 变量,只需使用 %
魔术命令,或者 %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 中设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文