Symbolic Link insanity - python

Ubuntu Support Template

Ubuntu Version:
Kubuntu 26.04

Desktop Environment (if applicable):
KDE Plasma

Problem Description:
Having recently installed upgraded to Kubuntu 26.04, I am bewildered that things I have known since I was a unix babe, my mother’s milk, so to speak, no longer appear valid. Specifically, that the which command tells you the location from which a command line will be run. And that symbolic links will be followed.

Consider the following sequence:

scohen@aigas:/usr/bin$ ll python*
lrwxrwxrwx 1 root root      19 Aug 19 10:15 python@ -> /usr/bin/python3.14
-rwxr-xr-x 1 root root     264 Nov 10  2025 python-argcomplete-check-easy-install-script*
lrwxrwxrwx 1 root root      10 Mar 21 02:46 python3@ -> python3.14
lrwxrwxrwx 1 root root      17 Mar 21 02:46 python3-config@ -> python3.14-config
-rwxr-xr-x 1 root root 8020928 Jun 19 05:46 python3.12*
lrwxrwxrwx 1 root root      34 Jun 19 05:46 python3.12-config@ -> x86_64-linux-gnu-python3.12-config
-rwxr-xr-x 1 root root 7481192 Jun 18 07:25 python3.14*
lrwxrwxrwx 1 root root      34 Jun 18 07:25 python3.14-config@ -> x86_64-linux-gnu-python3.14-config
scohen@aigas:/usr/bin$ which python
/usr/bin/python
scohen@aigas:/usr/bin$ python --version
Python 3.12.3
scohen@aigas:/usr/bin$ /usr/bin/python --version
Python 3.14.4

We see here that /usr/bin/python is a symbolic link to /usr/bin/python/3.14 and that which python returns /usr/bin/python as the executable to be run when python is typed.

However, executing python --version returns “Python 3.12.3” but
executing /usr/bin/python --version returns “Python 3.14.4”.

The only way I can make sense out of this is if something on my path ahead of
/usr/bin were pointing to another copy of python on my system.

But I looked at my path and no such python can be found in any of these path directories before the path gets to /usr/bin:

scohen@aigas:/usr/bin$ echo $PATH
/home/scohen/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
scohen@aigas:/usr/bin$ find -L /home/scohen/.local/bin -type f -name python
scohen@aigas:/usr/bin$ find -L /usr/local/sbin -type f -name python
scohen@aigas:/usr/bin$ find -L /usr/local/bin -type f -name python
scohen@aigas:/usr/bin$ find -L /usr/sbin -type f -name python
scohen@aigas:/usr/bin$ find -L /usr/bin -type f -name python
find: File system loop detected; ‘/usr/bin/X11’ is part of the same file system loop as ‘/usr/bin’.
/usr/bin/python

So the python I expected to be launched (/usr/bin/python) is the first python along the path.

I don’t know what a “file system loop” is, but could that be the problem here?
It doesn’t seem to be, because the /usr/bin/X11/python points to the 3.14 version:

lrwxrwxrwx 1 root root 19 Aug 19 10:15 python@ -> /usr/bin/python3.14

I just want python to bring up the same version everywhere!

But the python command is somehow finding 3.12 and I don’t understand this.

UPDATE: fixed a command line that I had not copied correctly initially. However, the entire thrust of the question remains the same.

Relevant System Information:
nothing pops out at me. This is pure linux question.

Screenshots or Error Messages:

What I’ve Tried:
Tried this. It does not bring me anything that would be on the path before /usr/bin:

scohen@aigas:/usr/bin$ find / -type l -lname "/usr/bin/python3.12" 2>/dev/null
/home/scohen/python/gmail/venv/bin/python
/home/scohen/python/bookmarks-converter/venv/bin/python3.12
/home/scohen/.local/share/SASpro/runtime.old/py312/venv/bin/python3.12

Before Posting:

What do the following commands reveal?

$ which -a python 

and just for kicks

$ strace -q -efile python --version


$ alias python3=gcc
$ python3 --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ /usr/bin/python3 --version
Python 3.12.3
$ 
scohen@aigas:/usr/bin$ which -a python
/usr/bin/python
/bin/python
scohen@aigas:/usr/bin$ /usr/bin/python version
scohen@aigas:/usr/bin$ /usr/bin/python --version
Python 3.14.4
scohen@aigas:/usr/bin$ /bin/python --version
Python 3.14.4
scohen@aigas:/usr/bin$ ll /bin/python
lrwxrwxrwx 1 root root 19 Aug 19 10:15 /bin/python@ -> /usr/bin/python3.14
scohen@aigas:/usr/bin$ ll /usr/bin/python
lrwxrwxrwx 1 root root 19 Aug 19 10:15 /usr/bin/python@ -> /usr/bin/python3.14

Both point to the same place which makes sense since /bin/python is just a symbolic link to /usr/bin/python3.14, as is /usr/bin/python

So nothing odd there, I don’t think.

Your other suggestion may point to something, but I’m not sure what:

scohen@aigas:/usr/bin$ strace -q -efile python --version
execve("/usr/bin/python", ["python", "--version"], 0x7fff67d045a8 /* 79 vars */) = 0
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libexpat.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/proc/sys/vm/overcommit_memory", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache", O_RDONLY|O_CLOEXEC) = 3
Python 3.14.4
+++ exited with 0 +++

It does produce the correct version number, unlike python --version.

That’s doesn’t make any sense. What happens if you uninstall the python-is-python3 package and run those commands?

gpmitch

1h

That’s doesn’t make any sense. What happens if you uninstall the python-is-python3 package and run those commands?

scohen@aigas:/usr/bin$ sudo apt remove python-is-python3
[sudo: authenticate] Password:        
Package 'python-is-python3' is not installed, so not removed

@gpmitch
Your suggestion of removing python-is-python3 gave me an idea. I installed it since it wasn’t installed already. That made no difference. I removed it. The apt remove command also instructed me to do sudo apt autoremove which removed a whole boatload of stuff. Remember, I just did an upgrade from 24.04 to 26.04.

Anyway, after all these actions, your strace command produced different results:


scohen@aigas:/usr/bin$ strace -q -efile python --version
strace: Cannot find executable 'python'

And yet:

scohen@aigas:/usr/bin$ python --version
Python 3.12.3

That only leaves @avb66 suggestion that you’ve set a shell alias for python pointing to the 3.12 version.

gpmitch

43m

That only leaves @avb66 suggestion that you’ve set a shell alias for python pointing to the 3.12 version.

Is THAT what @avb66 was suggesting? I couldn’t make head or tail of it. Why was he aliasing python to gcc? I thought he was a madman. But he was demonstrating how it could happen.

That was a brilliant suggestion, @abv66. Thanks! I did have that alias. Removing it solved the problem. Weird. I didn’t have python-is-python3 installed but it seems to have been replaced by that alias in .bash_aliases. Was that a thing once?

Thanks, @abv66. You nailed it even if I didn’t understand why the heck you were aliasing python to gcc. That alias was in my .bash_aliases file.

Was that a thing at some point in the past: don’t install python-is-python3 but instead use aliases?

You apparently had setup Python venv in the past and probably setup an alias for it.

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.