wxPython Phoenix with Anaconda Python

Hi!

I wanted to try wxPython Phoenix 4.0.0a1 on my Mac with Anaconda Python. Installing via pip install wxpython works fine, but when I run the following minimal example I get an error:

python -c “import wx; app = wx.App()”

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.

Any ideas what went wrong?

Thanks,

Clemens

With Anaconda Python on Mac OSX, you must use ‘pythonw’ instead of ‘python’ for wxPython applications.

See https://groups.google.com/d/msg/wxpython-users/T-H1Dbnnb1Q/RuXZuDo7AgAJ

···

–Matt

Another possible bug with Anaconda Python is: wxPython doesn’t load/run via the Jupyter Notebook (at least on my setup). Has anybody noticed this?

···

On Fri, Apr 28, 2017 at 5:16 PM, Matt Newville newville@cars.uchicago.edu wrote:

With Anaconda Python on Mac OSX, you must use ‘pythonw’ instead of ‘python’ for wxPython applications.

See https://groups.google.com/d/msg/wxpython-users/T-H1Dbnnb1Q/RuXZuDo7AgAJ

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

–Matt


*Wouldn’t you rather do Business with us? *
This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information. If you have
received it in error, please notify the sender immediately and delete the
original. Any use of the email by you is prohibited. If you have received
this communication in error, please notify the author by replying to this
e-mail immediately.


www.BintaSMS.com <http://www.bintasms.com/>
www.BintaComputers.net <http://www.bintacomputers.net/>

That’s because the Jupiter notebook does not use pythonw. It uses the regular python executable. It maybe possible to launch the notebook with pythonw, if so that might work for you. Otherwise we really need to get continuum to update the OS X python so that it supports windowing applications properly.

-CHB

···

On Fri, Apr 28, 2017 at 5:16 PM, Matt Newville newville@cars.uchicago.edu wrote:

With Anaconda Python on Mac OSX, you must use ‘pythonw’ instead of ‘python’ for wxPython applications.

See https://groups.google.com/d/msg/wxpython-users/T-H1Dbnnb1Q/RuXZuDo7AgAJ

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

–Matt


*Wouldn’t you rather do Business with us? *
This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information. If you have
received it in error, please notify the sender immediately and delete the
original. Any use of the email by you is prohibited. If you have received
this communication in error, please notify the author by replying to this
e-mail immediately.


www.BintaSMS.com <http://www.bintasms.com/>
www.BintaComputers.net <http://www.bintacomputers.net/>

You can use "pythonw" to launch ipython:

    Macbook:~>pythonw ~/anaconda3/bin/ipython
    Python 3.6.0 |Anaconda custom (x86_64)| (default, Dec 23 2016,
13:19:00)
    Type "copyright", "credits" or "license" for more information.

    IPython 5.3.0 -- An enhanced Interactive Python.
    ? -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help -> Python's own help system.
    object? -> Details about 'object', use 'object??' for extra details.
    Imported history from '/Users/Newville/.pyhist'

    In [1]: import wx ; app = wx.App() ; print(app) ; print(wx.PlatformInfo)
    <wx.core.App object at 0x10946b558>
    ('__WXMAC__', 'wxMac', 'unicode', 'unicode-wchar', 'wxOSX',
'wxOSX-cocoa', 'wx-assertions-on', 'phoenix', 'wxWidgets 3.0.3')

    In [2]: wx.__version__
    Out[2]: '4.0.0a1'

But this "pythonw trick" does not work with "jupyter-console" or
"jupyter-qtconsole" probably because they do some some crazy hacking of the
Python environment and PYTHONEXECUTABLE -- that is kind of the point of
Jupyter, after all.

But, of course, Anaconda is just messing around with us, and they actually
ship an almost-working Python so that "import wx" will work with

    ~/anaconda3/python.app/Contents/MacOS/python
~/anaconda3/bin/jupyter-console

that is *without* setting PYTHONEXECUTABLE. I've seen actual wx apps work
like this, but haven't tested it in any detail.

···

On Fri, Apr 28, 2017 at 4:20 PM, Umar Yusuf <bintacomputers@gmail.com> wrote:

Another possible bug with Anaconda Python is: wxPython doesn't load/run
via the *Jupyter Notebook* (at least on my setup). Has anybody noticed
this?

Thanks Matt, but I don’t have a pythonw in my Anaconda folder. I just have the one provided in /usr/bin. How do I use that to call the Anaconda Python executable? When I do e.g.

pythonw /usr/local/anaconda/bin/ipython

I get the following error:

Traceback (most recent call last):

File “/usr/local/anaconda/bin/ipython”, line 4, in

import IPython

ImportError: No module named IPython

Thanks,
Clemens

···

On Saturday, April 29, 2017 at 2:37:14 AM UTC+2, Matt Newville wrote:

On Fri, Apr 28, 2017 at 4:20 PM, Umar Yusuf bintaco...@gmail.com wrote:

Another possible bug with Anaconda Python is: wxPython doesn’t load/run via the Jupyter Notebook (at least on my setup). Has anybody noticed this?

You can use “pythonw” to launch ipython:

Macbook:~>pythonw ~/anaconda3/bin/ipython
Python 3.6.0 |Anaconda custom (x86_64)| (default, Dec 23 2016, 13:19:00)
Type “copyright”, “credits” or “license” for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
Imported history from '/Users/Newville/.pyhist'

In [1]: import wx ; app = wx.App() ; print(app) ; print(wx.PlatformInfo)
<wx.core.App object at 0x10946b558>
('__WXMAC__', 'wxMac', 'unicode', 'unicode-wchar', 'wxOSX', 'wxOSX-cocoa', 'wx-assertions-on', 'phoenix', 'wxWidgets 3.0.3')

In [2]: wx.__version__
Out[2]: '4.0.0a1'

But this “pythonw trick” does not work with “jupyter-console” or “jupyter-qtconsole” probably because they do some some crazy hacking of the Python environment and PYTHONEXECUTABLE – that is kind of the point of Jupyter, after all.

But, of course, Anaconda is just messing around with us, and they actually ship an almost-working Python so that “import wx” will work with

~/anaconda3/python.app/Contents/MacOS/python ~/anaconda3/bin/jupyter-console

that is without setting PYTHONEXECUTABLE. I’ve seen actual wx apps work like this, but haven’t tested it in any detail.

Does this have anything to do with wxPython?

You have 'ipython' but not the 'IPython' module, and not 'pythonw'? That
seems like something is wrong with the Anaconda installation. For me,
Anaconda on Mac OSX installs either to /Users/USERNAME/anaconda or
/Users/USERNAME/anaconda3 when doing 'install for me only' or /anaconda or
/anaconda3 when installing for all users.

I suggest reinstalling.

--Matt

···

On Tue, May 2, 2017 at 5:50 AM, Clemens Brunner <clemens.brunner@gmail.com> wrote:

Thanks Matt, but I don't have a pythonw in my Anaconda folder. I just have
the one provided in /usr/bin. How do I use that to call the Anaconda Python
executable? When I do e.g.

pythonw /usr/local/anaconda/bin/ipython

I get the following error:

Traceback (most recent call last):

  File "/usr/local/anaconda/bin/ipython", line 4, in <module>

    import IPython

ImportError: No module named IPython

Actually, I’m using Miniconda3 installed to /usr/local/anaconda. Apparently, you have to install the python.app package via conda in order to get pythonw. Meanwhile, I’ve switched to Python installed via Homebrew which works like a charm.

Clemens

···

On Tuesday, May 2, 2017 at 1:52:09 PM UTC+2, Matt Newville wrote:

You have ‘ipython’ but not the ‘IPython’ module, and not ‘pythonw’? That seems like something is wrong with the Anaconda installation. For me, Anaconda on Mac OSX installs either to /Users/USERNAME/anaconda or /Users/USERNAME/anaconda3 when doing ‘install for me only’ or /anaconda or /anaconda3 when installing for all users.