forkineye / ESPixelStick

Firmware for the ESPixelStick
http://forkineye.com/
528 stars 169 forks source link

python v python3 fix on OSX with python managed by homebrew #631

Closed 100ideas closed 1 year ago

100ideas commented 1 year ago

ESPixelStick Firmware Version 4.0-beta4

Hardware Version v3

Binary release or compiled yourself? release

Operating System (and version) osx 12.6.5 - python managed by homebrew

Web Browser (and version) n/a

Access Point n/a

Describe the bug when running java -jar ESPSFlashTool.jar the flash tool may fail because it tries to run python scripts by calling the python binary with 'python ...'. Makes sense, but on some systems, like mine, system python (which is out of date, thanks apple) is upgraded by homebrew package manager for packages that depend on it.

This issue is just for posterity, not sure that anything needs to be fixed (anyone who has same problem can hopefully find this issue discussion). So on my system, when I naively ran the flash update jar, it would fail because python isn't on the path anymore for some reason. Instead python3 is on the path for the homebrew installed python.

the fix was to symlink python -> python3 in the homebrew bin directory. Just fyi.

❯ java -jar ESPSFlashTool.jar
OS: mac os x / x86_64
Detected Mac
2023-05-14 17:56:49.296 java[24730:1286837] apply_selection_policy_once: prefer use of removable GPUs (via net.java.openjdk.java:GPUSelectionPolicy->preferRemovable)
java.io.IOException: Cannot run program "python": error=2, No such file or directory
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
    at com.forkineye.espsflashtool.ESPSFlashToolUI$ImageTask.exec(ESPSFlashToolUI.java:460)
    at com.forkineye.espsflashtool.ESPSFlashToolUI$ImageTask.doInBackground(ESPSFlashToolUI.java:512)
    at com.forkineye.espsflashtool.ESPSFlashToolUI$ImageTask.doInBackground(ESPSFlashToolUI.java:442)
    at java.desktop/javax.swing.SwingWorker$1.call(SwingWorker.java:304)
    at java.base/j
...
... etc

...ESPixelStick_Firmware-4.0-beta4  ........................................................................................................................................... 18:00:11
❯ which python

...ESPixelStick_Firmware-4.0-beta4  .................................................................................................................................... [ERROR]18:00:15
❯ which python3
/usr/local/bin/python3

...ESPixelStick_Firmware-4.0-beta4  ........................................................................................................................................... 18:00:26
❯ ln -s /usr/local/bin/python3 /usr/local/bin/python

...ESPixelStick_Firmware-4.0-beta4 ❯ python --version                                                                                                                       56s 18:01:08
Python 3.11.2

...ESPixelStick_Firmware-4.0-beta4 ❯ java -jar ESPSFlashTool.jar                                                                                                                18:01:15
OS: mac os x / x86_64
Detected Mac
2023-05-14 18:01:20.420 java[25054:1291818] apply_selection_policy_once: prefer use of removable GPUs (via net.java.openjdk.java:GPUSelectionPolicy->preferRemovable)
100ideas commented 1 year ago

this issue raises a problem that may occur on some OSX systems with vestigial python/python3 installs. It would be nice if the jar just worked out-of-the-box, but hopefully this issue solves the problem of any hypothetical future users who encounter this edge case vs. trying to solve it in jar.