Search code examples
ubuntupython-imaging-libraryvirtualenvimporterror

Encounter an error when want to run sherloq on Ubuntu: ImportError: cannot import name 'convert_dict_qtables' from 'PIL.JpegImagePlugin'


I'm encountering an issue when trying to run Sherloq on Ubuntu, and I'd appreciate some guidance on resolving it. Here are the details:

I've set up a virtual environment and cloned the Sherloq repository from GitHub. When attempting to execute the sherloq.py script, I encounter the following error:

(sq) ubuntu@ubuntu:~/Documents/GitHub/sherloq/gui$ python sherloq.py
WARNING:tensorflow:From /home/ubuntu/.virtualenvs/sq/lib/python3.10/site-packages/tensorflow/python/compat/v2_compat.py:107: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
Traceback (most recent call last):
  File "/home/ubuntu/Documents/GitHub/sherloq/gui/sherloq.py", line 34, in <module>
    from splicing import SplicingWidget
  File "/home/ubuntu/Documents/GitHub/sherloq/gui/splicing.py", line 13, in <module>
    from noiseprint.noiseprint_blind import genMappUint8
  File "/home/ubuntu/Documents/GitHub/sherloq/gui/noiseprint/noiseprint_blind.py", line 18, in <module>
    from .utility.utilityRead import resizeMapWithPadding
  File "/home/ubuntu/Documents/GitHub/sherloq/gui/noiseprint/utility/utilityRead.py", line 13, in <module>
    from PIL.JpegImagePlugin import convert_dict_qtables
ImportError: cannot import name 'convert_dict_qtables' from 'PIL.JpegImagePlugin' (/home/ubuntu/.virtualenvs/sq/lib/python3.10/site-packages/PIL/JpegImagePlugin.py)

This error seems to be related to the Pillow library, and specifically, the convert_dict_qtables function.

Has anyone else faced a similar issue with Sherloq? Any insights or suggestions on how to resolve this error would be greatly appreciated. Thank you!

I've tried doing the following command, but there doesn't seem to be a solution.

pip install Pillow --upgrade

Also try to uninstall and reinstall the Pillow package:

pip uninstall Pillow
pip install Pillow

The output of pip install Pillow is:

(sq) ubuntu@ubuntu:~/Documents/GitHub/sherloq/gui$ pip install Pillow
Collecting Pillow
  Obtaining dependency information for Pillow from https://files.pythonhosted.org/packages/7a/07/e896b096a77375e78e02ce222ae4fd6014928cd76c691d312060a1645dfa/Pillow-10.0.1-cp310-cp310-manylinux_2_28_x86_64.whl.metadata
  Using cached Pillow-10.0.1-cp310-cp310-manylinux_2_28_x86_64.whl.metadata (9.5 kB)
Using cached Pillow-10.0.1-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB)
Installing collected packages: Pillow
Successfully installed Pillow-10.0.1


Solution

  • https://pillow.readthedocs.io/en/stable/releasenotes/8.3.0.html

    convert_dict_qtables method no longer performs any operations on the data given to it, has been deprecated and will be removed in Pillow 10.0.0

    Install earlier version:

    pip install -U "Pillow < 8.3"