Document how to set environment variables for user notebooks
See original GitHub issueHi,
First of all, thank you for your great work on this project! It really is a pleasure to work with it.
I am trying to set an environment variable, so I can access it using %env MY_ENVIRONMENT_VARIABLE
within Jupyter notebooks. Despite trying for several hours, I have not been able to achieve this simple task.
I tried the following approaches:
- setting it in
.bashrc
- setting it in
.profile
- setting it in the SystemD configuration file
- adding a new configuration file in the directory
/opt/tljh/config/jupyterhub_config.d
- setting it via kernel parameters (see this StackOverflow answer)
- setting it in the spawner configuration
- setting it via
sudo tljh-config set user_environment.MY_ENVIRONMENT_VARIABLE my_value
- adding the environment variable name to the list of forwarded environment variables
I would be most grateful if somebody could tell me the correct way to set an environment variable on the Linux system so that I could use it within my notebooks. Thank you!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:14
Top Results From Across the Web
How to set env variable in Jupyter notebook - Stack Overflow
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...
Read more >Adding environment variables to notebooks that you own - IBM
Click Add a variable, specify the environment variable name and value, and click Save. For a list of supported built-in Jupyter notebook environment...
Read more >How to Set and List Environmental Variable in Python and ...
Step 1: Set Environmental Variable with Jupyter Magic. Simplest option to set environment variables in Jupyter Notebook and JupyterLab is to use magic...
Read more >Setting and Using Environment Variables in Jupyter Notebooks
Use the built-in %env magic command or pass the printenv or set commands to the operating system. Why is Jupyter Notebook not seeing...
Read more >Customizing User Environment
The user environment is the set of software packages, environment variables, and various files that are present when the user logs into JupyterHub....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Apologies for the delayed response, and thank you for opening this issue.
You can put standard JupyterHub config directives under
/opt/tljh/config/jupyterhub_config.d/<some-config-file-name>
. So you may create a file at/opt/tljh/config/jupyterhub_config.d/environment.py
and add the following contents:This should put the environment variables in your users’ notebook servers.
@yuvipanda I want to set env vars per user. How can I do that? Thanks in advance.