1

I am trying to follow the tutorials in the pyexiv2 tutorials page But due to some unknown reasons, it refuses to run, and I thought of seeking some advice from you.

`#this is my code
import pyexiv2
metadata = pyexiv2.ImageMetadata('test.png')
metadata.read()`

when I try to run this code in the terminal, with the python interpreter, in the folder which contains the image, 'test.png', following error is given.

`Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pyexiv2/metadata.py", line 107, 
in read
self.__image = self._instantiate_image(self.filename)
File "/usr/lib/python2.7/dist-packages/pyexiv2/metadata.py", line 74, 
in 
_instantiate_image
raise IOError(ENOENT, os.strerror(ENOENT), filename)
IOError: [Errno 2] No such file or directory: 'test.png'

` This is my setup. I am running ubuntu 16.04LTS on virtual machine on a Mac book, with macOS sierra. Python version is 2.7.12.

I used this guide to install pyexiv2. when I inspect the /usr/local/lib folder, it shows that the libexiv2 is installed there. What am I doing wrong here? and is there a better version of pyexiv2 to use? I am fairly new to using python.:) and thanks in advance

1 Answers1

0

This can be solved in two ways

1) Copy the file test.png in the same directory you have your python file with the code.

2) Provide a complete path. If, for example, you have test.png on your desktop, replace

metadata = pyexiv2.ImageMetadata('test.png')

with

metadata = pyexiv2.ImageMetadata('C:\\Users\\MYUSERPROFILENAME\\Desktop\\test.jpg')

where MYUSERPROFILENAME is your user profile. Hope this helps

Umar Dastgir
  • 688
  • 9
  • 25