googlefonts / fontdiffenator

Font comparison tool
Apache License 2.0
79 stars 13 forks source link

ImportError: cannot import name 'Image' from 'PIL' (unknown location) #72

Closed arrowtype closed 4 years ago

arrowtype commented 4 years ago

I'm attempting to use diffenator like diffenator ./path/font_A.ttf ./path/font_B.ttf, but getting an import error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/diffenator", line 6, in <module>
    from diffenator.__main__ import main
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/diffenator/__init__.py", line 6, in <module>
    from PIL import Image
ImportError: cannot import name 'Image' from 'PIL' (unknown location)

I've tried uninstalling and reinstalling Pillow, as suggested here: https://stackoverflow.com/questions/26505958/why-cant-python-import-image-from-pild

What else might I try to get this going? Thanks for any insights!

arrowtype commented 4 years ago

Ahh I see:

I had diffenator installed globally, and this was clashing with my virtual environment.

I deactivated my venv, then used pip uninstall fontdiffenator. I got an error saying I didn't have permissions for some of it.

▶ pip uninstall fontdiffenator
Uninstalling fontdiffenator-0.7.16:
  Would remove:
    /Library/Frameworks/Python.framework/Versions/3.7/bin/diffenator
    /Library/Frameworks/Python.framework/Versions/3.7/bin/dumper
    /Library/Frameworks/Python.framework/Versions/3.7/bin/fontdiffenator
    /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/diffenator/*
    /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fontdiffenator-0.7.16.dist-info/*
Proceed (y/n)? y
ERROR: Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 563, in move
    os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.7/bin/diffenator' -> '/private/var/folders/x0/q5zt3sx15ssdz5mjcm9rgvh40000gn/T/pip-uninstall-h46un_hx/diffenator'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 188, in main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/commands/uninstall.py", line 75, in run
    auto_confirm=options.yes, verbose=self.verbosity > 0,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 831, in uninstall
    uninstalled_pathset.remove(auto_confirm, verbose)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/req/req_uninstall.py", line 388, in remove
    moved.stash(path)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/req/req_uninstall.py", line 277, in stash
    renames(path, new_path)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/utils/misc.py", line 402, in renames
    shutil.move(old, new)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 578, in move
    os.unlink(src)
PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.7/bin/diffenator'

However, once I activated my venv again and once again used pip install fontdiffenator, it started working!