3

I'm trying to run Gooey which requires wxPython via PyCharm on my Mac (Sierra).

I have python and wxPython installed via homebrew and a virtual environment setup via the "Project Interpreter" preferences in PyCharm. Unfortunately, I'm getting the following 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.

I've seen various discussions of this issue around including : https://wiki.wxpython.org/wxPythonVirtualenvOnMac

Unfortunately, none of the solutions seems to work with my particular setup with PyCharm. Is there some way to specify a Framework build of python via PyCharm?

agf1997
  • 2,668
  • 4
  • 21
  • 36
  • This virtual env workaround may help, as the author there also uses homebrew. http://www.thebrokendesk.com/post/using-wx-python-in-a-virtual-environment/. After that, you will also need to configure PyCharm to run the python (or wrapper script) in the virtual environment. Look in PyCharm's preferences for Interpreter configurations, and select an appropriate configuration for your project. – RobinDunn Dec 02 '16 at 20:13
  • 1
    I have a script that executes the virtual environment version of python correctly. I can't figure out how to make pycharm execute the script. Editing the python interpreter options to point to the script rather then the python in venv/bin/ causes pycharm to produce an error that it's not a valid path to a python SDK. – agf1997 Jan 16 '17 at 22:49

1 Answers1

2

I've find a workaround for this issue.

  1. Check that you have wxPython installed, try to import wx from Python 3 interpreter.

    python3 -c 'import wx; print(wx.version())'

  2. That command returns 4.0.6 osx-cocoa (phoenix) wxWidgets 3.0.5 for me

  3. Start a new Python project in Pycharm, using venv and make sure you check the option Inherit global-site packages like this.
  4. Test.

Test example

import wx

if __name__ == '__main__':
    app = wx.App()
    window = wx.Frame(None, title="wxPython Frame", size=(300, 200))
    panel = wx.Panel(window)
    label = wx.StaticText(panel, label="Hello World", pos=(100, 50))
    window.Show(True)
    app.MainLoop()
Carlos
  • 41
  • 7