clj-python / clj-python/libpython-clj
NSWindow main thread error when trying to setup Gymnasium (openapi gym)
まだ誰も着手していません。
- 主要言語
- Clojure
- スター
- 1.2k
- フォーク
- 74
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hi, im trying to run some simple gymnasium stuff and getting the following error:
(require-python '[gymnasium :as gym])
(def env (gym/make "LunarLander-v2" :render_mode "human"))
; error (Temurin java 17) or crash (correto java 17)
(py. env reset :seed 42)
Execution error at libpython-clj2.python.ffi/check-error-throw (ffi.clj:707).
Traceback (most recent call last):
File "/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gymnasium/wrappers/time_limit.py", line 75, in reset
return self.env.reset(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gymnasium/wrappers/order_enforcing.py", line 61, in reset
return self.env.reset(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gymnasium/wrappers/env_checker.py", line 57, in reset
return env_reset_passive_checker(self.env, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gymnasium/utils/passive_env_checker.py", line 186, in env_reset_passive_checker
result = env.reset(**kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gymnasium/envs/box2d/lunar_lander.py", line 461, in reset
self.render()
File "/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gymnasium/envs/box2d/lunar_lander.py", line 699, in render
self.screen = pygame.display.set_mode((VIEWPORT_W, VIEWPORT_H))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pygame.error: NSWindow should only be instantiated on the main thread!
I'm on OSX Sonoma (silicon), python 3.11.6, Clojure 1.11.1 and java 17. I was actually about to write this as a crash report, but decided to try another Java 17 jvm and was able to get the error output instead.
In any case, is there something one can do with libpython-clj to setup the call such that it's on the main thread?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
報告されている Java および macOS のセットアップで Gymnasium LunarLander の例を再現することから始めます。ffi.clj:707 の libpython-clj2.python.ffi/check-error-throw と、スレッド処理に関する require-python/py. の呼び出し経路を調査します。呼び出しをメインスレッドで実行できるかどうかを確認し、サポートされる動作を文書化または実装できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- clojure, python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100