8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

wxPython の 'This program needs access to the screen. Please run with a' に対処する

Last updated at Posted at 2019-09-04

概要

  • Mac
  • pyenv
  • virtualenv
  • wxPython 4.0.6

こんな環境で wxPython さんを使おうとしました。しかし下記表示が出てきて、止まってしまいました。この問題に対応します。

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.

原因

wxPython は framework build の Python を必要とします。しかし pyenv がインストールしてくれる Python は、その framework build ではないようです。ゴメンなさいしないといけないのですが、 framework build の Python というのが何なのかは分かりません。とにかく framework build の Python が必要なんだ。(頭わるそう)

以下に、 framework build ではない Python を入手している様子を示します。

# 普通に Python を入手。
$ pyenv install 3.6.7

# virtualenv 作成。
$ pyenv virtualenv 3.6.7 lab-3.6.7
$ pyenv local lab-3.6.7

# pip upgrade。
$ pip install --upgrade pip

# wxPython 入手。
$ pip install wxPython

# 実行。
$ python foo.py
foo.py
import wx
wx.App()
結果
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.

解決

# framework build の Python を入手。
$ env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.6.7

# virtualenv 作成。
$ pyenv virtualenv 3.6.7 lab-3.6.7
$ pyenv local lab-3.6.7

# pip upgrade。
$ pip install --upgrade pip

# wxPython 入手。
$ pip install wxPython

# 実行。
$ python foo.py

これで問題なく動きました。

参考

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?