1

I've been trying to run the following code:

exif = pyexiv2.ImageMetadata(image_file)
exif.read()

on Python 3.7.0 and it yields an error AttributeError: module 'pyexiv2' has no attribute 'ImageMetadata'

I haven't used pyexiv2 before but the example illustrated here is similar to mine and I presume it works fine. I'm also not sure if pyexiv2 is fully supported for Python 3. Please Advise.

You can find the script I'm working with here

The Singularity
  • 2,428
  • 3
  • 19
  • 48

1 Answers1

4

This module uses

import pyexiv2

but you have to install py3exiv2 instead of pyexiv2 - you can see it in first line of Tutorial


But it uses some C/C++ code and it needs other modules in C/C++.

On Linux I had to install

apt install exiv2

apt install python3-dev

apt install libexiv2-dev

apt install libboost-python-dev

and later

pip install py3exiv2

(not pyexiv2)

See Dependences on page Developers

On Linux I have installed compiler C/C++ - gcc - but you may have to install it on other systems.

furas
  • 134,197
  • 12
  • 106
  • 148
  • Still fails to work after installing the following dependencies `exiv2` `boost-python3` and `py3exiv2` – The Singularity Jan 28 '21 at 10:22
  • did you uninstall `pyexiv2` ? Maybe you have two Python installed and you install `py3exiv2` in other Python - you may use `python -m pip install ...` to install for Python which you use to run `python script.py` – furas Jan 28 '21 at 12:33
  • I would first unistall `pyexiv2` and check if still can `import pyexiv2` to confirm that it was really uninstalled. And later I would use `python -m pip install py3exiv2` to install it - and it should compile it - so you should see if it has problem to find needed elements. It needs modules with `*-dev` which have source code in `C/C++` – furas Jan 28 '21 at 12:53
  • I believe your method has worked to some extent but now the `import pyexiv2` yields an error. I've reported that issue [here](https://stackoverflow.com/questions/65936143/symbol-not-found-referenced-from-expected-in-flat-namespace-macos-big-sur) – The Singularity Jan 28 '21 at 13:17