简体   繁体   English

wxpython-phoenix在osx / ipython / pycharm上需要python框架

[英]wxpython-phoenix requires python framework on osx/ipython/pycharm

Running the sample hello-world code offered on wxpython-phoenix website throws a known error on osx. 运行wxpython-phoenix网站上提供的示例hello-world代码会在osx 引发已知错误。 Hints at possible solutions can be found here , and here , but none seem to work with ipython and pycharm. 可以在这里找到可能的解决方案的提示,在这里 ,但似乎没有一个与ipython和pycharm一起使用。

QUESTION: How to work around this known error, using ipython from within pycharm? 问题:如何使用pycharm中的ipython解决这个已知错误?

Set up: 设定:

OSX 10.12.5 Sierra OSX 10.12.5 Sierra
ipython 3.7.1 in a conda venv 在conda venv中的ipython 3.7.1
pycharm CE 2018.3 pycharm CE 2018.3
(also fails from command line, and from jupyter notebook) (也从命令行和jupyter笔记本中失败)

code ran : (from wxpython getting started page) 代码运行 :(从wxpython入门页面)

import wx
app = wx.App()
frm = wx.Frame(None, title="Hello World")
frm.Show()
app.MainLoop()

error message 错误信息

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.

full traceback 完全追溯

---------------------------------------------------------------------------
SystemExit                                Traceback (most recent call last)
<ipython-input-1-5af94fb54276> in <module>
      3 
      4 # Next, create an application object.
----> 5 app = wx.App()
      6 
      7 # Then a frame.

~/anaconda3/envs/py37/lib/python3.7/site-packages/wx/core.py in __init__(self, redirect, filename, useBestVisual, clearSigInt)
   2100                 # TODO: more description is needed for wxMSW...
   2101 
-> 2102             raise SystemExit(msg)
   2103 
   2104         # This has to be done before OnInit

SystemExit: 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.

Note: This question is similar to: 注意:这个问题类似于:
- that one which was for python2.7, but did not receive an answer - 那是一个python2.7,但没有得到答案
- that one which offers outdated fixes for regular python, outside of pycharm - 那个在pycharm之外为常规python提供过时修复的那个
Other questions like this one , are obsolete for the new release of wxpython. 对于新版本的wxpython来说,像这样的其他问题已经过时了。

When using conda environments you need to install the python.app package and then use pythonw to run applications that use wxPython. 使用conda环境时,您需要安装python.app包,然后使用pythonw运行使用wxPython的应用程序。

On osx, the command line is: (as shown here ) 在OSX,命令行是:(如图所示这里

conda install -c anaconda python.app

You will see the following message; 您将看到以下消息; confirm to proceed. 确认继续。

 The following packages will be SUPERSEDED by a higher-priority channel: python.app: 2-py37_9 --> 2-py37_9 anaconda 

With pycharm , it is necessary to change the project interpreter: 使用pycharm ,有必要更改项目解释器:

--> go to: - >转到:

preferences
  project interpreter
    add interpreter
      conda environment
        anaconda (or anaconda3)
          bin
            pythonw 
select pythonw
apply
ok

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM