clj-python / clj-python/libpython-clj
Python Interop on a (32-bit, ARM) Raspberry Pi Zero?
還沒有人認領這個 Issue。
- 主要語言
- Clojure
- 星號
- 1.2k
- 分支
- 74
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Thanks for this project! I enjoyed the talk from this year's Conj and it made me want to dive right in.
My use case is somewhat unique, I think: I'm trying to use Python to drive some hardware I have soldered to the GPIO pins on a Raspberry Pi Zero. The Pi is a 32-bit ARM processor, and Python works great on it... but Python interop has been giving me a bit of trouble.
Here's what we're working with:
$ ldconfig -p | grep python
libpython3.7m.so.1.0 (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libpython3.7m.so.1.0
libpython3.7m.so (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libpython3.7m.so
libpython2.7.so.1.0 (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libpython2.7.so.1.0
libpython2.7.so (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libpython2.7.so
and Java:
$ java -version
openjdk version "1.8.0_152"
OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8.0_152-b76)
OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, mixed mode, Evaluation)
I'm using Python 3.7 to drive the hardware, and Python itself runs fine.
Likewise, I can run Clojure (both JARs and Clojure in the REPL) without any issue.
But when I try to run Python from within Clojure via the REPL, here's what happens:
=> (require '[libpython-clj.python :as py])
nil
=> (py/initialize!)
Jan 09, 2020 3:05:16 AM clojure.tools.logging$eval1906$fn__1909 invoke
INFO: Executing python initialize!
Jan 09, 2020 3:05:17 AM clojure.tools.logging$eval1906$fn__1909 invoke
INFO: Startup info detected: {:python-home "/usr", :lib-version "3.7", :libname "python3.7m", :java-library-path-addendum "/usr/lib"}
Jan 09, 2020 3:05:17 AM clojure.tools.logging$eval1906$fn__1909 invoke
INFO: Reference thread starting
Jan 09, 2020 3:05:18 AM clojure.tools.logging$eval1906$fn__1909 invoke
INFO: Library python3.7m found at [:system "python3.7m"]
Execution error (IllegalArgumentException) at libpython-clj.jna.base/eval22533$fn$G (base.clj:20).
No implementation of method: :->py-object-ptr of protocol: #'libpython-clj.jna.base/PToPyObjectPtr found for class: nil
The error repeats itself if you try any other commands:
=> (py/run-simple-string "print('Hello')")
Execution error (IllegalArgumentException) at libpython-clj.jna.base/eval22533$fn$G (base.clj:20).
No implementation of method: :->py-object-ptr of protocol: #'libpython-clj.jna.base/PToPyObjectPtr found for class: nil
I started the repl using lein repl in a new project root.
The project was scaffolded with the lein new app command.
Do you see anything off the top of your head that may be the root cause of these issues?
My gut tells me it's one of three things:
- The 32-bit ARM processor, and everything that goes along with that
- The Zulu Embedded Java 8 JDK
- Something dumb that I haven't noticed yet.
Any thoughts as to why this is happening, or is there any more information I could provide?
Really appreciate your time. Thank you!
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
在所描述的 32 位 ARM Raspberry Pi 環境中,使用 libpython-clj.python/initialize! 和 py/run-simple-string 從 Clojure REPL 重現此故障。從 libpython-clj/jna/base.clj:20 開始,追蹤 PToPyObjectPtr 通訊協定回報的 nil 值;完成的標準是確定此故障是否由平台、Java 執行環境或專案設定所造成,並記錄一個經過驗證的解決方案。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java, python, raspberry-pi
- 領域
- embedded-iot, tooling
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100