I'm getting some weird behaviour when running python....
# which python
/root/.pyenv/shims/python
# /root/.pyenv/shims/python -V
Python 3.9.7
# python -V
Python 3.8.10
Like waaaatttt!!
So I check my PATH... looks good
# echo $PATH
/root/.pyenv/bin:/root/.pyenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
What is going on?!
The system is installed from a Dockerfile...
FROM ubuntu:20.04
# set shell locale to UTF8
ENV LANG=C.UTF-8
# system utils
RUN apt-get update && apt-get upgrade -y && \
apt-get install -qq wget curl git zip jq
# python build libraries
RUN DEBIAN_FRONTEND="noninteractive" \
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils \
tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev python3-pip && \
ln -s /usr/bin/python3 /usr/bin/python
# pyenv - used to set the build version of a python package
# Usage: pyenv install 3.9.7 && pyenv global 3.9.7
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \
echo 'export PATH="$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH"' >> ~/.bashrc
and then I install and enable the required version of python with...
# pyenv install 3.9.7
Downloading Python-3.9.7.tar.xz...
-> https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tar.xz
Installing Python-3.9.7...
Installed Python-3.9.7 to /root/.pyenv/versions/3.9.7
# pyenv global 3.9.7
# pyenv which python
/root/.pyenv/versions/3.9.7/bin/python
# /root/.pyenv/versions/3.9.7/bin/python -V
Python 3.9.7
# which python
/root/.pyenv/shims/python
# /root/.pyenv/shims/python -V
Python 3.9.7
# python -V
Python 3.8.10
At least pip works...
# pip -V
pip 21.2.3 from /root/.pyenv/versions/3.9.7/lib/python3.9/site-packages/pip (python 3.9)
# pip3 -V
pip 21.2.3 from /root/.pyenv/versions/3.9.7/lib/python3.9/site-packages/pip (python 3.9)
UPDATE FOR @tripleee
# type -a python
python is /root/.pyenv/shims/python
python is /usr/bin/python
python is /bin/python