Pip cannot install tkinter

for my Python Projects I need the (custom)tkinter modules, which are available through pip.
But after I installed python-pip-git from AUR, there always comes following error:

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
    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.

Even after doing the provided tips in the error message, like doing sudo pacman -S python-tk or the pipx thing, it’s the same error or nothing could be found. I also searched up for other solutions like on Stack Overflow, but there’s only ubuntu-specific help.

Currently, Python version Python 3.11.3 is installed.

After creating a virtual environment, you need to activate the virtual environment first, and then use pip to install whatever module you wish to install.


Let’s say you are inside your project directory project/

To create a virtual environment

python -m venv ./venv

This will create a directory venv/ inside project/

After that, you activate your virtual environment by sourcing (assuming that your current working directory is still project/) a shell script virtual environment directory

source ./venv/bin/activate

Your shell prompt should change after sourcing this script.

Only then you start installing your modules.

pip install <whatever>

Then, while your virtual environment is still activated, you can import those installed modules and run your python scripts (inside the same terminal session where the virtual environment is still activated)

And by the way, I thought you only need to install tk to use tkinter?

sudo pacman -Syu tk

Thanks for your help!
The sudo pacman -Syu tk helped me out.
Do you know how I also get customtkinter?