Tu4n3r
Tu4n3r

Reputation: 441

Linux Mint Cinnamon error opening settings (No module named 'PIL')

since I updated Cinnamon to 5.0.6 I can't access any entry under 'Preferences', nothing happens. When I try to open from CLI I have the following :

#> cinnamon-settings
No module named 'PIL'

I searched a lot but nothing suits my problem. I understand that it's a problem with Python and PIL module or the newer module Pillow but none of the solutions provided works for me.

Some informations :


#> python --version
Python 3.8.10

#> /usr/bin/env python
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 

#> pip -V
pip 21.3 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)

#> pip show Pillow
Name: Pillow
Version: 8.4.0
Summary: Python Imaging Library (Fork)
Home-page: https://python-pillow.org
Author: Alex Clark (PIL Fork Author)
Author-email: [email protected]
License: HPND
Location: /home/xxx/.local/lib/python3.8/site-packages
Requires: 
Required-by: image, imageio, img2pdf, matplotlib, ocrmypdf, pikepdf, reportlab, scikit-image


Do you have any ideas ?

Thanks

EDIT : I found this on the Cinnamon 5.0.6 changelog, I think this is the problem

  • cinnamon-settings: Remove ~/.local and /usr/local from python's module search paths

Upvotes: 2

Views: 2019

Answers (3)

Viktor
Viktor

Reputation: 333

here is similar question and the solution https://forums.linuxmint.com/viewtopic.php?t=364028

In my case, I need to reinstall all requested modules

like:

apt-get install --reinstall python3-pil
apt-get reinstall python3-requests
apt-get reinstall python3-six
apt-get reinstall python3-urllib3

Now it is working without commenting lines in /usr/share/cinnamon/cinnamon-settings/bin/util.py

Upvotes: 12

Rostyslav Mazepa
Rostyslav Mazepa

Reputation: 81

In the file /usr/share/cinnamon/cinnamon-settings/bin/util.py I commented lines 9 and 10 :

 if path.startswith(("/usr/local", os.path.expanduser("~/.local"))):
 continue

to

# if path.startswith(("/usr/local", os.path.expanduser("~/.local"))):
#    continue

Upvotes: 4

Tu4n3r
Tu4n3r

Reputation: 441

I found a workaround, reverting a change made in 5.0.6

In the file /usr/share/cinnamon/cinnamon-settings/util.py I commented lines 9 and 10 :

#!/usr/bin/python3

def strip_syspath_locals():
    import sys
    import os

    new_path = []
    for path in sys.path:
        if path.startswith(("/usr/local", os.path.expanduser("~/.local"))):
            continue
        new_path.append(path)

    sys.path = new_path

to

#!/usr/bin/python3

def strip_syspath_locals():
    import sys
    import os

    new_path = []
    for path in sys.path:
        # if path.startswith(("/usr/local", os.path.expanduser("~/.local"))):
        #    continue
        new_path.append(path)

    sys.path = new_path

This may not be the best way to fix this problem, but it worked.

Do you see a better solution or is it a bug in Cinnamon ?

Upvotes: 2

Related Questions