Can't install python-regex

I am not used to install python modules with pip. Instead I prefer to use a docker container.
Anyway I have got an error message installing calibre and the reason is that if I try to install python-regex I am getting the following error message:

pacman -S python-regex
resolving dependencies...
looking for conflicting packages...

Packages (1) python-regex-2023.10.3-1

Total Installed Size:  2,39 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                                                                                                           [##############################################################################################] 100%
(1/1) checking package integrity                                                                                                                         [##############################################################################################] 100%
(1/1) loading package files                                                                                                                              [##############################################################################################] 100%
(1/1) checking for file conflicts                                                                                                                        [##############################################################################################] 100%
error: failed to commit transaction (conflicting files)
python-regex: /usr/lib/python3.11/site-packages/regex/__init__.py exists in filesystem
python-regex: /usr/lib/python3.11/site-packages/regex/__pycache__/__init__.cpython-311.pyc exists in filesystem
python-regex: /usr/lib/python3.11/site-packages/regex/__pycache__/_regex_core.cpython-311.pyc exists in filesystem
python-regex: /usr/lib/python3.11/site-packages/regex/__pycache__/regex.cpython-311.pyc exists in filesystem
python-regex: /usr/lib/python3.11/site-packages/regex/__pycache__/test_regex.cpython-311.pyc exists in filesystem
python-regex: /usr/lib/python3.11/site-packages/regex/_regex.cpython-311-x86_64-linux-gnu.so exists in filesystem
python-regex: /usr/lib/python3.11/site-packages/regex/_regex_core.py exists in filesystem
python-regex: /usr/lib/python3.11/site-packages/regex/regex.py exists in filesystem
python-regex: /usr/lib/python3.11/site-packages/regex/test_regex.py exists in filesystem
Errors occurred, no packages were upgraded.

if I try to list, the package is there:

pip3 list | grep -i regex
regex                        2023.6.3

But if I try to remove, I am getting this:

pip3 uninstall regex
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    python-xyz', where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Arch-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.
    
    If you wish to install a non-Arch packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have python-pipx
    installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

That happens when another program (pip for example) installs files in a directory which is managed by pacman/pamac or the local db was purged: /var/lib/pacman/local/ so that pacman doesn’t know that it exists, thus it conflicts here.

In that case only --overwrite="/usr/lib/python3.11/site-packages/regex/*" helps here.

Maybe used sudo pip or similar in the past?

I try to keep software under pacman management but calibre is one program I install outside of pacman. There is a distro-agnostic linux calibre installer directly available from their web site: https://calibre-ebook.com/download_linux

I use that download and I have no problem installing python-regex using pacman. The package directly from calibre, currently version 7.2.0, is usually a step ahead of the package in the Manjaro repositories, which is now at version 7.1.0.

Calibre will notify you if there’s an update available.