On 28/03/2023 15:51, Jim web wrote:


Sorry to hear about your wife, commiserations to you both.

In article <a545ac1d-311a-32cd-d5f1-775a26e06...@macfh.co.uk>, MacFH - C E Macfarlane - News <n...@macfh.co.uk> wrote:

Might as well be sure, so what happens when you type:
    python --version

If that comes up with 3.7 as desired, what do you get for:
    pip --help

It gives me  Python 2.7.17

However if I look in usr/lib/ I can see directories for Python
2.7, 3, 3.6, 3.7, and 3.8.

Different versions of Java, Perl, and Python can be a right royal PITA - seemingly endless updates seem to require anything based on them that you are using needing programs to be rewritten and/or recompiled.

If you have a genuine need for different versions as opposed to having arrived with multiple versions merely by happenstance, one possible workaround is to have some means of determining the default version for a given shell instance. For example, in Unbuntu 18, I get ...

# which python
/usr/bin/python
# ls -al /usr/bin/python
/usr/bin/python->python2.7

... and ...

# ls -al /usr/bin/python*

... is also quite instructive, but would be overkill to transcribe in its entirety here!

This gives the possibility of a given shell instance pointing that link to whichever version of python that it needs, either directly or via an environment variable, as it launches ...

# ln -s -f /usr/bin/python2.7 /usr/bin/python

... or ...

# export PYTH_VER=2.7
# ln -s -f /usr/bin/python${PYTH_VER} /usr/bin/python

... however, although I have seen it done this way, I DON'T RECOMMEND IT, because if you have two shells running simultaneously requiring different versions of python [the rest of this sentence is left as an exercise to the programmer]!

Better is to use a different alias within each shell ...

# python --version
Python 2.7.17
# alias python=/usr/bin/python3.6
# python --version
Python 3.6.9

If this works, fine, but if, say, more than one change to the environment is needed, perhaps because the PATH or LIB variables need to include the directories for a different versions of Python or some such, then use an environment variable in all the settings so that between different shells you have to change only the value of that:

# python --version
Python 3.6.9
# export PYTH_VER=2.7
# alias python=/usr/bin/python${PYTH_VER}
# python --version
Python 2.7.17

HTHs


_______________________________________________
get_iplayer mailing list
get_iplayer@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/get_iplayer

Reply via email to