0

As an absolute beginner, I'm trying my hand at my first python project by following this how-to:

https://blog.matthewgove.com/2022/05/13/how-to-bulk-edit-your-photos-exif-data-with-10-lines-of-python/

Using my Mac Terminal, I have installed the required exif library using pip3 install exif. When I do it again, it tells me:

Requirement already satisfied: exif in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (1.6.0)

So it must have installed it. However, when I try to run my python code in Visual Studio Pro, the import statement from exif import Image as ExifImage is causing:

/usr/bin/python3 "/Users/johndoe/Library/CloudStorage/OneDrive/Desktop/Crafting Day/exif-fix.py"
johndoe@C02DN12DMD6R ~ % /usr/bin/python3 "/Users/johndoe/Library/CloudSto
rage/OneDrive/Desktop/Crafting Day/exif-fix.py"
Traceback (most recent call last):
  File "/Users/johndoe/Library/CloudStorage/OneDrive/Desktop/Crafting Day/exif-fix.py", line 2, in <module>
    from exif import Image as ExifImage 
ModuleNotFoundError: No module named 'exif'
johndoe@C02DN12DMD6R ~ % 

I also tried moving my project to the root user folder, but I got the same result.

Can anyone help me figure out why my code is not able to import the installed library?

  • Where the error message says `Requirement already satisfied: exif in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (1.6.0)`, what do you think this means exactly? In particular, what do you think it is telling you, about *where the Python version is*, for which the package has been installed? If you use the command `/usr/bin/python3 "/Users/johndoe/Library/CloudSto rage/OneDrive/Desktop/Crafting Day/exif-fix.py"`, what version of Python do you think will run? Can you see why this might cause the package to appear not to be installed? – Karl Knechtel Jul 26 '23 at 07:28
  • Don't use /usr/bin/python3 (full path to some interpreter) when you use just pip3 (version discovered via PATH). It's also preferred to use pip as -m pip (where is some interpreter - full path or link) for this exact reason - so that you know you're using the pip for the exact python interpreter you want. So here `/usr/bin/python3 -m pip install exif` would fix it, but you should probably just use `python3` without path – h4z3 Jul 26 '23 at 07:32
  • (If you find that the system will not allow you to use Pip with `/usr/bin/python3`, that's because it was deliberately not provided for that Python installation. This is a security feature; in this case, you are meant to use the system's package manager to maintain that version of Python. Since you already apparently installed the package for that Python, simply use that Python to run the code instead. I am not putting any of this in an answer, because this is an extremely well visited topic; please read the linked duplicate. These are just some quick hints as to how it applies.) – Karl Knechtel Jul 26 '23 at 07:34

0 Answers0