How to use wxpython in an ipython notebook or console

2.3k views Asked by At

I am using the anaconda python distribution (python version 2.7) and I would like to be able to use wxpython either in a notebook or at least in an ipython console through the anaconda spyder app (their IDE). I am running into what is apparently a common problem which is due to the anaconda python environment not being recognized as a framework with GUI access.

In fact, I am able to launch a wxpython app when working directly in ipython when launched from the command line. However, when trying to get an app to run from either the spyder IDE ipython console or an ipython notebook I get this error:

This program needs access to the screen. Please run with a Framework build of python, and only when you are logged in on the main display of your Mac.

If anyone knows a workaround for this I would very much appreciate your advice.

Thanks!

2

There are 2 answers

4
petem On

In an ipython notebook before you run a cell invoking wxpython functions you have to insert the %gui magic:

%gui wx

0
George Wyatt On

I believe simply using pythonw vs. python helped when I was using a MacBook.