맥북에 python을 설치하고, wxPython 라이브러리를 이용해서 프로그램을 작성하려고 했다.
1. wxPython 설치
pip3를 이용하여 설치하였다.
pip3 install wxPython
2. wxPython 버전 확인
터미널을 열어 다음의 명령어를 입력한다.
python3
import wx
print(wx.version())
3. IDE에서 예제 코드 작성 후 실행
# First things, first. Import the wxPython package.
import wx
# Next, create an application object.
app = wx.App()
# Then a frame.
frm = wx.Frame(None, title="Hello World")
# Show it.
frm.Show()
# Start the event loop.
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.
구글링을 통해 아래의 링크를 발견하였고, 똑같이 변경하니 해결되었다.
How to run wxPython with the python.org installer on macOS 12.4 (Monterey)
I want to install python from python.org and have it work with wxPython in a terminal on macOS: Install python 3.9.13 using the macOS 64-bit universal2 installer Install wxPython using pip - pip3
stackoverflow.com
wx 패키지의 core.py 파일에서
if not self.IsDisplayAvailable():
부분을 찾은 후
if False:
위와 같이 바꿔주었다.
성공!!!

'Language' 카테고리의 다른 글
| 언어 별 주석 정리 (0) | 2022.03.24 |
|---|
댓글