Celeb Glow
news | March 17, 2026

Nautilus and Nemo don't recognize python 3 files

Nautilus and Nemo use two different icons for python files:

Two different icons for python files

But I want them to show the python icon for all python files.

mimetype gives the same result for both files:

$ mimetype *.py
buy_test.py: text/x-python
candlestick_test.py: text/x-python

file -i gives different outputs:

$ file -i buy_test.py
buy_test.py: text/x-python; charset=us-ascii
$ file -i candlestick_test.py
candlestick_test.py: text/x-objective-c; charset=us-ascii

The output for candlestick_test.py is wrong but this file is shown with the python icon. No idea why.

Somebody here had the same problem:Ubuntu file manager is not showing proper icons

But the answer he got, doesn't work for me:

$ grep -r 'text/x-python' /usr/share/thumbnailers

No output.

I think the main diffenrence between these python files is the shebang:

$ head -n2 buy_test.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
$ head -n2 candlestick_test.py
# -*- coding: utf-8 -*-
"""

When I use this shebang (python 2) ...

#!/usr/bin/env python

... there is a python icon, too.

How do Nautilus and Nemo choose file icons?

EDIT:

Some additional information:

There is a python icon if I use one of these shebangs:

#!/usr/bin/env python
#!/usr/bin/python

There is no python icon if I use one of these shebangs:

#!/usr/bin/env python3
#!/usr/bin/python3

So it looks like python3 is a problem.

EDIT 2:

xdg-mime query filetype FILENAME returns the MIME type matching the shebang:

$ xdg-mime query filetype buy_test.py
text/x-python3
$ xdg-mime query filetype candlestick_test.py
text/x-python

And when I change candlestick_test.py's file extension to .py3, the python icon disappears and xdg-mime query filetype returns text/x-python3.

EDIT 3:

I found a new source of information:

$ gio info ~/python/buy_test.py | grep icon standard::icon: text-x-python3, text-x-generic standard::symbolic-icon: text-x-python3-symbolic, text-x-generic-symbolic, text-x-python3, text-x-generic
$ gio info ~/python/candlestick_test.py | grep icon standard::icon: text-x-python, text-x-generic standard::symbolic-icon: text-x-python-symbolic, text-x-generic-symbolic, text-x-python, text-x-generic

So I guess, I have to link text-x-python3 files to text-x-python icons somehow.

3

2 Answers

Finally I could fix it!

As far as I understand, Nemo and Nautilus try to load a file named text-x-python3.svg from /usr/share/icons/[MyTheme]/mimes/[ActualIconSize]/. If there is such a file in ~/.local/share/icons/[MyTheme]/mimes/[ActualIconSize]/ it has a higher priority. But none of these directories existed for my theme: Humanity-Dark.

So Nemo/Nautilus try to find that icon in another theme. In /usr/share/icons/Humanity-Dark/index.theme is defined which theme to try next:

$ grep Inherits /usr/share/icons/Humanity-Dark/index.theme
Inherits=Humanity,Adwaita,hicolor

Next try is Humanity. There are icons for text-x-python but not for text-x-python3. So I did:

mkdir -p ~/.local/share/icons/Humanity-Dark/mimes/48
cp /usr/share/icons/Humanity/mimes/48/text-x-python.svg ~/.local/share/icons/Humanity-Dark/mimes/48/text-x-python3.svg

Same for icon sizes 16 and 22. Now it looks as expected:

Python icons as expected

Maybe this solution is helpful for someone else.

I had a nearly identical problem in Thunar. I had a slightly different solution. I'm using the elementary Xfce icon theme, so change the commands below as appropriate:

sudo ln -s /usr/share/icons/elementary-xfce/mimes/32/text-x-python.png /usr/share/icons/elementary-xfce/mimes/32/text-x-python3.png
sudo ln -s /usr/share/icons/elementary-xfce/mimes/48/text-x-python.png /usr/share/icons/elementary-xfce/mimes/48/text-x-python3.png
sudo ln -s /usr/share/icons/elementary-xfce/mimes/64/text-x-python.png /usr/share/icons/elementary-xfce/mimes/64/text-x-python3.png
sudo update-icon-caches /usr/share/icons/*

The last command to refresh the icon cache was necessary for me to see the changes in Thunar. After running the commands above I simply refreshed the directory in Thunar and everything was working as expected.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy