EspHoMaTriXv2 icon indicating copy to clipboard operation
EspHoMaTriXv2 copied to clipboard

Unable to compile latest version - missing libmagic???

Open trizmark opened this issue 1 year ago • 8 comments

Question

I've been running this FW on my ulanzi for a while and last time I compiled it was back in Sept. (ESPHome 2023.8.3). I wanted to add a couple of extra icons to the display, but for some reason I'm unable to compile it at all. I tried both on my Win and my Mac machine, but no luck.

Any idea what am I missing?

I have libmagic and pylibmagic installed and no amount of searching on the web yielded any useful results...

% pip install libmagic             
Requirement already satisfied: libmagic in /opt/homebrew/lib/python3.11/site-packages (1.0)
% pip install pylibmagic
Requirement already satisfied: pylibmagic in /opt/homebrew/lib/python3.11/site-packages (0.5.0)

Additional information

  • used Hardware: Ulanzi TC001

    • EspHoMaTriXv2 version: 2024.3.0

Logs

ERROR Unable to import component ehmtxv2:
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/esphome/loader.py", line 169, in _lookup_module
    module = importlib.import_module(f"esphome.components.{domain}")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/zmarkella/Documents/Git_repos/ESPHomeConfigs/ulanzi/.esphome/external_components/d62ebc04/components/ehmtxv2/__init__.py", line 10, in <module>
    import esphome.components.image as espImage
  File "/opt/homebrew/lib/python3.11/site-packages/esphome/components/image/__init__.py", line 10, in <module>
    from magic import Magic
  File "/opt/homebrew/lib/python3.11/site-packages/magic/__init__.py", line 209, in <module>
    libmagic = loader.load_lib()
               ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/magic/loader.py", line 49, in load_lib
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation
ERROR Unable to import component animation:
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/esphome/loader.py", line 169, in _lookup_module
    module = importlib.import_module(f"esphome.components.{domain}")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/homebrew/lib/python3.11/site-packages/esphome/components/animation/__init__.py", line 5, in <module>
    import esphome.components.image as espImage
  File "/opt/homebrew/lib/python3.11/site-packages/esphome/components/image/__init__.py", line 10, in <module>
    from magic import Magic
  File "/opt/homebrew/lib/python3.11/site-packages/magic/__init__.py", line 209, in <module>
    libmagic = loader.load_lib()
               ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/magic/loader.py", line 49, in load_lib
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation
ERROR Unable to import component image:
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/esphome/loader.py", line 169, in _lookup_module
    module = importlib.import_module(f"esphome.components.{domain}")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/homebrew/lib/python3.11/site-packages/esphome/components/image/__init__.py", line 10, in <module>
    from magic import Magic
  File "/opt/homebrew/lib/python3.11/site-packages/magic/__init__.py", line 209, in <module>
    libmagic = loader.load_lib()
               ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/magic/loader.py", line 49, in load_lib
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation

Additional context

Add any other context about the problem here.

trizmark avatar Mar 14 '24 08:03 trizmark

try brew doctor to make sure it's not a homebrew issue

noiob avatar Mar 27 '24 15:03 noiob

Thanks for the tip, but that doesn't explain why I get the exact same issue on my Windows machine.

trizmark avatar Mar 27 '24 16:03 trizmark

Thanks for the tip, but that doesn't explain why I get the exact same issue on my Windows machine.

pip install "pillow==10.2.0"
pip install libmagic
pip install python-magic-bin

andrewjswan avatar Jun 21 '24 15:06 andrewjswan

Out of curiosity, why not run ESPHome in Docker? All the dependencies are part of the image... actually, as you might guess from andrewjswan's comment, there's on ongoing issue regarding ESPHome being stuck with an outdated version of Pillow...

Also, this definitely isn't an issue with EHMTXv2... it's an ESPHome issue. Try this thread: https://github.com/esphome/issues/issues/5427

trip5 avatar Jun 21 '24 16:06 trip5

Docker on Windows sounds funny, there is nothing complicated about installing ESPHome in Python.

andrewjswan avatar Jun 21 '24 16:06 andrewjswan

If you say so but this thread and that thread say otherwise. Literally takes seconds to update ESPHome, no futzing about with versions or Python environments. And it's speed is close enough to running on bare-metal.

And yes, lol it runs in Windows on the Linux Subsystem (which the Docker install painlessly updates). It's a bit odd compared to Linux installs as it can also run Windows containers (I have no idea about that) but I had to run it on my work notebook because I keep ESPHome devices at work. It's a bit slow though, probably because Windows itself is using 1/4 of the CPU cycles.

trip5 avatar Jun 21 '24 17:06 trip5

If you say so but this thread and that thread say otherwise. Literally takes seconds to update ESPHome, no futzing about with versions or Python environments. And it's speed is close enough to running on bare-metal.

In Python it's all the same, I haven't had any problems for over 4 years. Everything is simple and hassle-free. To be precise I have 3 ESPHome, one in HA OS, and two in Windows in Python, no problems...

And yes, lol it runs in Windows on the Linux Subsystem (which the Docker install painlessly updates). It's a bit odd compared to Linux installs as it can also run Windows containers (I have no idea about that) but I had to run it on my work notebook because I keep ESPHome devices at work. It's a bit slow though, probably because Windows itself is using 1/4 of the CPU cycles.

It's easy when it's easy. But I have Windows 11 and Core 2 Duo, and when installing Docker, it just says, "Sorry, but I won't install on this hardware, much less work with it." But Python works.

andrewjswan avatar Jun 21 '24 21:06 andrewjswan

https://github.com/esphome/esphome/pull/7365 should fix this issue

guillempages avatar Sep 01 '24 19:09 guillempages

this is not direct related to ehmtx, its more a platform thing.

lubeda avatar Nov 01 '24 20:11 lubeda