Want to easily see and change environment variables when working with Jupyter notebooks?
Managing environment variables across different notebooks and machines can be challenging, to help make it easier, Jupyter comes with the magic command %env. The %env magic command in Python is part of the IPython environment and is installed by default with Jupyter. %env allows you to get, set, or list environment variables directly within the interactive environment without having to use the os module.
Want to see what environment variables are loaded into your notebook?
%env
Need to set an environment variable just for this notebook?
%env VAR=‘value’
Conclusion
These commands make it easy to manage environment variables within the notebook, enabling interactive workflows where you can adjust the environment in the middle of a session.
Read the full IPython documentation here.