[opensource-dev] specifying wich python binary to use?

Henri Beauchamp sldev at free.fr
Sat Sep 22 07:00:31 PDT 2018


On Sat, 22 Sep 2018 15:43:14 +0200, Lance Corrimal wrote:

> I have python 2 and python 3 installed on my system, is there a way to specify 
> which python version autobuild should use? by default it tries python3, which 
> fails.

Depending on your distribution, you may specify (or not) which Python version
is to be used when invoking 'python', with: alternatives --config python

If it does not work, you may trick the build system by creating a "python"
link to the python2 binary and then changing the PATH so that your link is
found first. E.g. from a terminal:

mkdir -p ~/bin
ln -s /usr/bin/python2 ~/bin/python
export PATH="$HOME/bin:$PATH"

then from the same terminal, launch the build.

When running any command, a script ran from that terminal will first look into
the bin/ subdirectory of your home directory before looking in the rest of the
$PATH directories, and "python" (linked to python2) will be found there...

You may also make this a permanent feature for your login, by chanching
~/.bashrc and putting in it the same: export PATH="$HOME/bin:$PATH"

For a system-wide change, create the link in /usr/local/bin and change the
system-wide default PATH (usually to be found in /etc/bashrc) to list
/usr/local/bin as the first directory.

Henri.


More information about the opensource-dev mailing list