22

Using Ubuntu 17.04. After update Python 3.5 to 3.6 via terminal according to https://askubuntu.com/a/865569/695385 still showing that version is 3.5.3.

~$ python3 --version
Python 3.5.3

How is this installed?

4
  • 1
    How did you update it?
    – edwinksl
    Jun 6 '17 at 23:53
  • 1
    Then you call it using python3.6. python3 will remain symlinked to python3.5 and you should keep it that way. Look into virtual environments like Oli wrote in his answer.
    – edwinksl
    Jun 7 '17 at 0:41
  • Thanx, now I`ve to find out how to use virtualenv. Jun 7 '17 at 0:47
20

I had the same problem, I did the following instruction to resolve it:

After installing Python3.6:

To make python3 use the new installed Python 3.6 instead of the default 3.5 release, run following 2 commands:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

Finally, switch between the two Python versions for python3 via the following command:

sudo update-alternatives --config python3

Then select the /usr/bin/python3.6 -- automode in choices menu, for me that was 0 row.


[Result]:

$ python3 -V
Python 3.6.9

Or:

$ python3 --version
Python 3.6.9
1
  • Warning: the gnome-terminal may fail to launch after this. It apparently depends on python3 to be 3.5. Apr 11 '19 at 0:33
10

How did you upgrade? I suspect you may have a python3.6 binary somewhere.

Generally speaking, you never want to replace /usr/bin/python or /usr/bin/python3 with your own fruity versions. Important parts of Ubuntu require their stable Python environments, and largely speaking, that is incompatible with you mucking around.

That all said, having a /usr/bin/python3.6 (or /usr/local/bin/python3.6, or whatever in your path) would be fine. If you don't want to type all that in each time, you might want to look at virtualenv and the various wrapper automation options for it. This has the additional bonus of not threatening your system's site_packages with your development work.

1
5

Installing and upgrading to Python3.6 requires the command

sudo apt-get upgrade python3.6
2
  • This command installs all the packages. @Sreenath
    – alper
    Mar 8 '19 at 17:37
  • But when I do python3 it opens python3.5.. Daah
    – nirala
    Dec 13 '19 at 9:13
1

Use Docker and get the Python image for whatever version you want. It's also easy to update.

FROM python:3.6

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        postgresql-client \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . .

EXPOSE 8000
1
  • Could you expand a bit, for readers with low docker background ? What are we supposed to do with that file ?
    – kebs
    Nov 3 '20 at 22:22
0

Other option is using PPA:

https://launchpad.net/~jonathonf

sudo add-apt-repository ppa:jonathonf/python-3.7
sudo apt-get update
sudo apt-get install python3.7

And add Python 3.7 to update-alternatives with priority 1.

0

I've done this on Ubunutu 16.04:

sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.8
-2

Visit https://www.python.org/downloads/source/ to find the latest version. Check the current stable version before pulling for install.

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.