If the output of
type -a python
is /usr/bin/python
, and if there is no second line displayed, then pyenv is only setup partially.
You should have seem as first line something like
/home/username/.pyenv/shims/python
That means your pyenv is not setup properly. It is only set up partially.
What's missing is the pyenv shims which redirect to the correct version of python.
Probably your search path contains:
/home/username/.pyenv/bin
, but it is missing /home/username/.pyenv/shims
(Following comments updated 2021-01-06):
Normally you should have three lines in your ~/.bashrc
The first two (or something equivalent), that you seem to have are:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
On the other hand what you seem to be missing is a line, that looks like:
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
or a more elaborate but in most cases identical line:
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
Try to add one of these missing lines to your .bashrc and see whether pyenv is working better.
You could also add ~/.pyenv/shims/python
manually to your searchpath, but normally this should have been done by the eval "$(pyenv init -)"
command
if ~/.pyenv/shims
is already in your search path, then check with
ls ~/.pyenv/shims
whether the directory exists and contains an executable named python.
Normally this should have been added latest after having done a pyenv install 3.8.0
Addendum 2022-01-15:
Please note that the way pyenv is initialized changed.
If you had an older pyenv version and you updated the cloned repository you have probably something like
eval "$(pyenv init -)"
in your ~/.bash_profile
(or your ~/.zshrc or ... depending on your shell)
This has to be changed to something lile
eval "$(pyenv init -)"
eval "$(pyenv init --path)"
type -a python
? – Veiipython3 -V
command? I think thepython
command defaults to python 2.x.x on some machines. This is the case for me. – Abash