clj-python / clj-python/libpython-clj

NSWindow main thread error when trying to setup Gymnasium (openapi gym)

Đang mở
#257 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Clojure
Star
1.2k
Fork
74
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ Gymnasium LunarLander với thiết lập Java và macOS được báo cáo. Kiểm tra libpython-clj2.python.ffi/check-error-throw tại ffi.clj:707 và đường dẫn gọi của require-python/py. để xử lý luồng. Hoàn tất có nghĩa là xác định được liệu lệnh gọi có thể chạy trên luồng chính hay không, đồng thời ghi lại hoặc triển khai hành vi được hỗ trợ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
clojure, python
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.