Mac上的wxPython和PyCharm [英] wxPython and PyCharm on Mac

查看:253
本文介绍了Mac上的wxPython和PyCharm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行Gooey,它需要通过Mac(Sierra)上的PyCharm运行wxPython.

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

我通过homebrew安装了python和wxPython,并通过PyCharm中的项目解释器"首选项设置了虚拟环境.不幸的是,我收到以下错误:

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.

我已经看到了有关此问题的各种讨论,其中包括: https://wiki.wxpython.org/wxPythonVirtualenvOnMac

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

不幸的是,在我使用PyCharm进行的特定设置中,所有解决方案似乎都不起作用.有没有办法通过PyCharm指定python的Framework构建?

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?

推荐答案

我已经找到解决此问题的方法.

I've find a workaround for this issue.

  1. 检查是否已安装wxPython,请尝试从Python 3解释器导入wx.

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

python3 -c'导入wx; print(wx.version())'

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

该命令为我返回 4.0.6 osx-cocoa(phoenix)wxWidgets 3.0.5

测试示例

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

这篇关于Mac上的wxPython和PyCharm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆