What is the purpose of $HOME/.local

It is not directly connected to Python, but Pip uses it. Let's start from the beginning. First you should understand, what the /usr directory is used for:

In current Unices, /usr is where user-land programs and data (as opposed to 'system land' programs and data) are.

It should be used for data installed by the system, i.e. official packages of the distribution.

The /usr/local directory mirrors the structure of the /usr directory, but can be used by system administrators to install local or third party packages for all users.

The ~/.local directory now has the same purpose just for a single user.

Usually you'll install your packages with the default package manager using the /usr directory. But since you're using Pip as package manager for your Python modules, these are installed in ~/.local.

So basically pip might have created ~/.local or just any other programm writing data to one of the directories located there. ~/.local/share for example is used by most applications to store their data.


$HOME/.local is where user applications place their files and folders in the user's home directory.

According to the Home Directory section of the file-hierarchy(7) man-page, user-specific data should be split among the following sub-directories within $HOME/.local:

  • ~/.local/bin for executables that shall appear in the user's $PATH search path. In Python's case this might be a tool like pipenv.
  • ~/.local/lib for static, private vendor data that is compatible with all architectures. In Python's case these are libraries like requests.
  • ~/.local/share for resources shared between multiple packages. In Python's case this might be the virtualenvs. It is also part of the XDG Base Directory Specification where it is mentioned as the default value of $XDG_DATA_HOME.

From the above observations it should become clear that $HOME/.local has nothing in particular to do with Python itself. pip install --user putting its files into $HOME/.local simply means it is compliant with the recommendations published by freedesktop.org.

If you install packages with sudo pip install, it will distribute the package files according to the Filesystem Hierarchy Standard into the /usr hierarchy instead, which follows the same logic at system-level, just as your distribution's package manager does.

Tags:

Python

Pip