Redundant python folders?

Under my ~/.local/lib folder there are three folders for different python versions, namely, 3.13, 3.14, and 3.15.

I suspect that each time I upgrade Fedora, python is also updated. Can I safely delete the older versions and leave the most recent one?

Fedora upgrades shouldn’t touch ~/.local/lib. The Fedora-shipped Python will be under /usr.

So the answer depends on what is installing into ~/.local/lib.

The python folder contains one sub-folder: site-packages. I know of one particular programme that is using python and adding content there. Since Fedora might be using the newer version of python, I guess it creates a python folder with the respective version.

So you could try renaming the older folders to 3.13-bak and 3.14-bak or something.

If that doesn’t break anything then it suggests they’re safe to delete.

Any time a user creates a venv using python it will build that subdirectory under ~/.local/lib for the appropriate python version being used in the virtual environment.

I have these

$ ls .local/lib
python3.11  python3.12  python3.13  python3.14  Qt

and each contains the following

$ ls .local/lib/python*
.local/lib/python3.11:
site-packages

.local/lib/python3.12:
site-packages

.local/lib/python3.13:
site-packages

.local/lib/python3.14:
site-packages

This is because a venv does not necessarily require using the exact version of python that is standard for the global system so a local version specific for the user is installed to support the app in use.

My global system under /usr/lib contains python versions 3.12, 3.13, 3.14, and 3.15 which reveals the updates over time that my system has been installed and upgraded.

Any time a user creates a venv using python it will build that subdirectory under ~/.local/lib for the appropriate python version being used in the virtual environment.

A venv keeps its packages in lib/pythonX.Y/site-packages inside the venv’s own directory, so creating one doesn’t add folders under ~/.local/lib (https://docs.python.org/3/library/venv.html). ~/.local/lib/python3.13/site-packages is the per-user site directory, where pip installs packages for Python 3.13 when it runs as a normal user (https://docs.python.org/3/library/site.html).

Drafted with AI, reviewed by me.

pip install foo as a non-root user will install package foo in the user python sitedir, which depends on python version and is the one you mentioned.

So the behavior is not odd, even though it is typical for odd Fedora versions - those are the ones where we upgrade Python to a new major version :wink:

Unless you keep around (and need) a previous python version, you can delete the old subdirectories. I used to use them as a reminder of what to pip install, but these days I rather keep a package list for that.

I agree.

I misspoke when I likened it to a venv, but rather you are correct in that .local/lib/python3.13 will contain user installed python packages (not installed using sudo or root privileges.)

In other words, if the OP deletes those directories he will lose any python packages he may have installed as the user for those versions of python, as well as (potentially) disrupting the installation history for python packages (if such a history is maintained.)

Removal should be done by uninstalling the relevant python packages for each version intended to be removed before deleting the directories.

What installation history?

You would need to use pip to uninstall the package for the version to be removed. I do not know if there is a history retained for what is installed, but I do know the user installed packages can mostly be identified by looking in the ~/.local/lib/python<version>/site-packages directory.

I realised that the python3.13 folder was empty, so I deleted it. The python3.14 folder wasn’t empty, but I renamed it and it was not recreated. I suspect that it is redundant as well – in my system – and the python programs I’m using are using the default python version. I confirm this because both the 3.14 and the 3.15 folders have copies of the same sub-folders.