-1

I have tried every way I can to install Python 3.8 or 3.9. I have both tried the deadsnakes library and the compile method. Both them report success, but when I do a “python3 -V” it always returns “Python 3.6.9”.

It is either not installing (weird because it says it is successful) or not reporting correctly. Any thoughts?

1

Only the Ubuntu / Debian packages name the executable for Python 3 python3. If you're compiling and installing from source, then the Python 3 executable should just be python. What is the output of python -V and which python?

I've had great success with asdf to run newer versions of Python and Ruby. I've added the instructions here to install Python 3.9.2 with asdf for the Bash shell.

Install dependencies for asdf.

sudo apt install curl git

Download the v0.8.0 branch with Git.

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0

If you use Bash, then integrate asdf with your shell using the following.

echo ". $HOME/.asdf/asdf.sh" >> ~/.bashrc

Reload your shell configuration.

source ~/.bashrc

Add the Python plugin.

asdf plugin add python

Install the dependencies required to build Python.

sudo apt install make build-essential libssl-dev zlib1g-dev libbz2-dev \
  libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils \
  tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Install the desired version of Python.

asdf install python 3.9.2

Set the global Python version for your user.

asdf global python 3.9.2
2
  • ‘Python -V’ = ‘Python 2.7.17’ ‘Python3 -V’ = ‘Python 3.6.9’ ‘Which Python’ = ‘/usr/bin/Python’ Not sure what is going on. I am using the standard terminal app installed on Elementary OS - I assume it is Bash but I don’t know how to determine that. Thanks for any help you can offer. – DMHamm Mar 2 at 18:08
  • I think following the instructions for installing with asdf should get Python 3 on your path. It will just be named python instead of python3 though. – jwillikers Mar 2 at 22:35
0

What could be happening is that you have multiple versions of python on your machine. It also happens with Java, PHP and others. If this is the case you can try to set an alias (on ~/.bashrc) for the version that you want, for example:

alias python='/usr/bin/python3.9'

Or using a tool like update-alternatives:

update-alternatives --list python

update-alternatives --config python

A nice tutorial can be found on this post. It is for debian distributions but it does not change too much on Elementary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.