LeoHsiao1 / pyexiv2

Read and write image metadata, including EXIF, IPTC, XMP, ICC Profile.
GNU General Public License v3.0
197 stars 39 forks source link

Cannot import library #89

Closed chbndrhnns closed 2 years ago

chbndrhnns commented 2 years ago

I tried to install and import the library and it fails like this. Is it maybe due to my Macbook M1 platform? And is there something I or you could do about it?

❯ python
Python 3.9.9 (main, Nov 30 2021, 16:21:05)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyexiv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jo/src/scratch/guess-timestamp/.venv/lib/python3.9/site-packages/pyexiv2/__init__.py", line 6, in <module>
    from .core import *
  File "/Users/jo/src/scratch/guess-timestamp/.venv/lib/python3.9/site-packages/pyexiv2/core.py", line 1, in <module>
    from .lib import exiv2api
  File "/Users/jo/src/scratch/guess-timestamp/.venv/lib/python3.9/site-packages/pyexiv2/lib/__init__.py", line 25, in <module>
    ctypes.CDLL(os.path.join(lib_dir, 'libexiv2.dylib'))
  File "/Users/jo/.pyenv/versions/3.9.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/jo/src/scratch/guess-timestamp/.venv/lib/python3.9/site-packages/pyexiv2/lib/libexiv2.dylib, 0x0006): tried: '/Users/jo/src/scratch/guess-timestamp/.venv/lib/python3.9/site-packages/pyexiv2/lib/libexiv2.dylib' (no such file), '/usr/local/lib/libexiv2.dylib' (no such file), '/usr/lib/libexiv2.dylib' (no such file)
>>> import os
>>> import ctypes
>>>
>>> path = '/Users/jo/src/scratch/guess-timestamp/.venv/lib/python3.9/site-packages/pyexiv2/lib/libexiv2.dylib'
>>>
>>> os.path.isfile(path)
False
LeoHsiao1 commented 2 years ago

Yes, pyexiv2 provides build packages that support only the AMD64 platform. Requires users to compile manually on other platforms. When Python fails to import a dynamically linked library, either the file in that path does not exist, or it is incompatible with the current operating system.

chbndrhnns commented 2 years ago

I resolved it like described in https://github.com/LeoHsiao1/pyexiv2/issues/90