[英]wxpython-phoenix requires python framework on osx/ipython/pycharm
運行wxpython-phoenix網站上提供的示例hello-world代碼會在osx 上引發已知錯誤。 可以在這里找到可能的解決方案的提示,在這里 ,但似乎沒有一個與ipython和pycharm一起使用。
問題:如何使用pycharm中的ipython解決這個已知錯誤?
設定:
OSX 10.12.5 Sierra
在conda venv中的ipython 3.7.1
pycharm CE 2018.3
(也從命令行和jupyter筆記本中失敗)
代碼運行 :(從wxpython入門頁面)
import wx
app = wx.App()
frm = wx.Frame(None, title="Hello World")
frm.Show()
app.MainLoop()
錯誤信息
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.
完全追溯
---------------------------------------------------------------------------
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.
注意:這個問題類似於:
- 那是一個python2.7,但沒有得到答案
- 那個在pycharm之外為常規python提供過時修復的那個
對於新版本的wxpython來說,像這樣的其他問題已經過時了。
使用conda環境時,您需要安裝python.app
包,然后使用pythonw
運行使用wxPython的應用程序。
在OSX,命令行是:(如圖所示這里 )
conda install -c anaconda python.app
您將看到以下消息; 確認繼續。
The following packages will be SUPERSEDED by a higher-priority channel: python.app: 2-py37_9 --> 2-py37_9 anaconda
使用pycharm ,有必要更改項目解釋器:
- >轉到:
preferences
project interpreter
add interpreter
conda environment
anaconda (or anaconda3)
bin
pythonw
select pythonw
apply
ok
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.