1

I'm setting environment variable in jupyterhub_config.py file for first time launch of service. Next time if i restart i need to use the same env variable. But the env variable is not available once i restart jupyterhub service.

## code changes in /opt/miniconda/etc/jupyterhub/jupyterhub_config.py ##
import os
#first time
os.environ["JUPYTERHUB_MY_VARIABLE"] = "setFirstTime"
#after restart, re-use
if 'JUPYTERHUB_MY_VARIABLE' in os.environ:
    print("Use next time after restart")

Does restarting jupyterhub service clear environment variables?

veeresh patil
  • 1,168
  • 1
  • 11
  • 18
  • You might want to use `dotenv` library and a `.env` file. See https://stackoverflow.com/a/61029741/1207049 – marekful Jul 28 '21 at 05:20
  • This way i have to maintain ".env" file, I do not want to create a new env file. Because am setting env variable as part of logic in code itself (for first time) and use it again. Is there a way without maintaining env file. – veeresh patil Jul 28 '21 at 06:45

0 Answers0