7

I just installed Ubuntu, and it comes with default a default Python version of 3.6.7. I installed Python 3.7.3 by following these instructions (changing 3.7.2 to 3.7.3 as appropriate) and it all worked well.

Now I have two Python 3 versions, both working. I would now like to remove Python 3.6.7 and keep 3.7.3.

How should I go about doing this?

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
User19
  • 165
  • 4
    Don't remove python if you want to keep using Ubuntu. Things will break if you do, so think of plan B now. – mikewhatever Apr 06 '19 at 19:32
  • @mikewhatever thanks, but when i do pip3 install .. it doesn't work it just installs for python 3.6 and python 3.7 doesn't get installation – User19 Apr 06 '19 at 19:33
  • 2
    @User1984 Then why didn't you ask for that? Please read http://xyproblem.info And the solution would be to try pip3.7. – Murphy Apr 06 '19 at 19:50
  • @Murphy i got this error when i ran pip3.7 install requests Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.7/site-packages/chardet' Consider using the --user option or check the permissions. – User19 Apr 06 '19 at 19:57
  • @Murphy this isn't xyproblem i asked because i wanted to remove version3.6, why should i keep more than one python3 version on my pc but turns out i can't so i referred to another solution – User19 Apr 06 '19 at 20:02
  • 1
    "why should i keep more than one python3 version on my pc" For the exact reason you were given by @mikewhatever. BTW, this would be a good time to take the [tour] and read [ask]. – Murphy Apr 06 '19 at 20:11

2 Answers2

7

I installed python 3.7 and then:

sudo update-alternatives --config python3

See what is there, normally it will be an error, then:

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

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

sudo update-alternatives --config python3

Choose 2 and you are done.

ThunderBird
  • 1,955
Tom
  • 71
6

Ubuntu uses python for many system related functionalities. You must not remove the Python installation that is preinstalled by it, or you'll end up with a broken system, perhaps beyond repair.

If for some reason you need to use a more recent Python version, just install it parallel and call it explicitely, e. g. with python3.7, as python3 will point to the default installation. The same goes for pip, which may need the --user option or being called with sudo depending on the permissions.

Murphy
  • 1,677
  • can you give me example of using pip3.7 that will work i.e pip3.7 install requests --user ?? – User19 Apr 06 '19 at 20:18