'Arch mingw: Using a python version installed with pacman

I am currently using the MSYS2 Building Platform which uses an arch shell to allow users to install their packages via the pacman package manager. On this shell, neither $PYTHONHOME nor $PYTHONPATH are set, and issuing which python3 returns /usr/bin/python3. I have used pacman to install a python version I would actually like to be using, which is located in /mingw64/lib/python3.9/. My first approach was to issue

export PYTHONPATH=/mingw64/lib/python3.9/
exec bash

but this did not change the output of which python3 or which python. I have also tried modifying the PYTHONPATH variable in a virtual environment but this has not worked either. How can I made the adjustments necessary so that the aliases python and python3 automatically point to the desired python installation?



Solution 1:[1]

The solution was to find the location of the mingw64 python installation by issuing

pacman -Q1 | grep /mingw64/bin/

and then appending it to $PATH by issuing

export PATH=mingw-w64-x86_64-python:$PATH

and then reloading the python alias paths by issuing

exec bash

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dmmpie