"Magic Commands" in Jupyter Notebook not supported to set environment variable
See original GitHub issueI’m trying to work with Blinka in Jupyter Notebook, and it seems to work only if I set the required environment variable in the command prompt before running the kernel. Since I’m running Anaconda on Windows, this would look like:
set BLINKA_NOVA=1
jupyter notebook
If I do this, I can import board
with no problem.
If I try to run the magic command or shell command in a Jupyter Notebook cell, it does not seem to work:
!set BLINKA_NOVA=1
or
%env BLINK_NOVA=1
I can see that the variable has been set by calling !set
or %env
. However, when I run import board
I get the Board not supported None
error message. I’m not sure if this is a bug in Blinka or Jupyter Notebook, but any help would be appreciated!
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
How to set env variable in Jupyter notebook
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 >Built-in magic commands — IPython 8.7.0 documentation
This is useful if you wish to use a different editor from your typical default with IPython (and for Windows users who typically...
Read more >How to Set and List Environmental Variable in Python and ...
Simplest option to set environment variables in Jupyter Notebook and JupyterLab is to use magic functions. There two types of magic commands:.
Read more >Top 8 magic commands in Jupyter Notebook
1. List all magic commands. · 2. Run a file. · 3. Get an execution time. · 4. List all variables. · 5....
Read more >Run magic command not passing variable
Hello everyone, I have many Jupyter notebooks with different ipywidgets programs in them. Now, I wanna make a “Master notebook” and use the ......
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
I would recommend following @makermelissa’s suggestion to set the environment variable globally. The reason that it can be done in Mac/Linux is that it uses a different type of shell than Windows. Here’s an article from Jake Vanderplas’ book that explains a bit more: https://jakevdp.github.io/PythonDataScienceHandbook/01.05-ipython-and-shell-commands.html
It’s not a bug but a limitation of the Windows operating system. If you are using Windows Subsytem Linux, I believe that the command will work (though I haven’t tried it since I don’t have a Windows system handy). Good luck @ShawnHymel. FYI you can ask questions about Jupyter in the Jupyter Discourse site too (http://discourse.jupyter.org).
@ShawnHymel, Another option that might work is to search for
env
in your run bar on Windows and go to Edit the system environment variable and set a system variable through there. Then it should be system wide. You may need to reboot after doing that.