15

I have Python 3.5 installed.I previously installed Python 3.4 from source and managed to uninstall it somehow. Now if I try to install Python 3.4 through apt-get install python3.4 , it returns

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libpython3.4-minimal' for regex 'python3.4'
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Directly executing python3.4 --version does't work as well. What should I do?

  • Python 3.4 is not in the official repositories for Ubuntu 16.04. Do you really need Python 3.4? – edwinksl Jul 24 '16 at 7:22
  • Yes I need Python 3.4 to run kivy. Also, does this mean that python 3.4 is already installed somewhere on my computer? If I can't use it then at least I want to get completely rid of it. – Prithvish Baidya Jul 24 '16 at 7:45
  • 1
    kivy can run on Python 3.5 as far as I can tell. – edwinksl Jul 24 '16 at 7:50
  • 1
    I have another machine running windows, and while most of the time I am on my linux machine, I sometimes also need to get on my windows machine. Since Python 3.5 is not supported by kivy on Windows, I want to use 3.4 on my linux machine as well since I work on the same project from both machines and working with 3.4 on one and with 3.5 on the other can cause issues (or can it?). – Prithvish Baidya Jul 24 '16 at 7:57
  • Ah okay, it makes more sense now. I will write up something now. – edwinksl Jul 24 '16 at 8:16
20

As you can see from http://packages.ubuntu.com/search?keywords=python3.4&searchon=names&suite=xenial&section=all, there is no package for python3.4 for Ubuntu 16.04. You can compile and install Python 3.4 from source, but if you are not familiar with doing it or prefer to install packages using the APT package manager, I would recommend installing it from a well-known PPA that provides a variety of versions of Python for many Ubuntu versions.

  1. Add the deadsnakes PPA (read more about it at https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa):

    sudo add-apt-repository ppa:deadsnakes/ppa
    
  2. Install python3.4:

    sudo apt-get update
    sudo apt-get install python3.4
    

According to https://askubuntu.com/a/682875/15003,/usr/bin/python3 should still be symlinked to /usr/bin/python3.5. Therefore, if you want to call Python 3.4, you would need to type the full path to it, which is /usr/bin/python3.4. To avoid accidentally breaking other programs, I strongly recommend you to not change the symlink that /usr/bin/python3 points to and instead just use /usr/bin/python3.4 whenever you need to call Python 3.4.

Alternatively, a popular method to manage multiple versions of Python, which I personally recommend, is to use virtualenv. You can read more about it at https://virtualenv.pypa.io/en/stable/; further elaboration of it in this post seems too far off the intent of the question.

  • 2
    Unfortunately the repository is not supported anymore. – tomasz74 Nov 10 '16 at 13:49
  • @tomasz74 Huh, I only just realized that. Thanks for the info. – edwinksl Dec 16 '16 at 21:28
  • The repo moved to launchpad.net/~deadsnakes/+archive/ubuntu/ppa. So it's now sudo add-apt-repository ppa:deadsnakes/ppa. Only works for Ubuntu up to 16.04 – Suor Dec 11 '17 at 5:21
  • @Suor Thanks for the information; I have updated my post. – edwinksl Dec 11 '17 at 5:43

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.