Fix Python – How to set env variable in Jupyter notebook

Question

Asked By – Ehab AlBadawy

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?

Now we will see solution for issue: How to set env variable in Jupyter notebook


Answer

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.)

See: http://ipython.readthedocs.io/en/stable/interactive/magics.html

This question is answered By – michael

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0