NSWindow main thread error when trying to setup Gymnasium (openapi gym)
还没有人认领这个 Issue。
评估
调研方向
首先使用报告中的 Java 和 macOS 设置复现 Gymnasium LunarLander 示例。检查 ffi.clj:707 中的 libpython-clj2.python.ffi/check-error-throw,以及 require-python/py. 的调用路径以了解线程处理。完成的标准是确定该调用能否在主线程上运行,并记录或实现受支持的行为。
由索引模型根据 Issue 内容生成。
描述
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?
- 主要语言
- Clojure
- 星标
- 1.2k
- 派生
- 74
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
clj-python/libpython-clj 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 48/100
clj-python/libpython-clj#280 ·
-
难度 4/5 3-5 天 新手友好度 38/100
clj-python/libpython-clj#275 · 5 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 58/100
clj-python/libpython-clj#273 ·
-
难度 4/5 3-5 天 新手友好度 25/100
clj-python/libpython-clj#271 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
clj-python/libpython-clj#270 · 1 条评论 ·
查看 clj-python/libpython-clj 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 1/5 1 小时以内 新手友好度 88/100
-
.Team/Metabot Priority:P3
难度 2/5 1-3 小时 新手友好度 72/100
-
needs triage
难度 1/5 1 小时以内 新手友好度 90/100