question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Magic Commands" in Jupyter Notebook not supported to set environment variable

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
willingccommented, Feb 22, 2020

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

2reactions
makermelissacommented, Feb 21, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found