0

I am using ubuntu 16.04. Ubuntu 16.04 comes with python2 and python 3.5 and Apparently I wanted python3.7 so I followed some instructions from a site and installed python3.7 manually by compiling its files and installing its dependencies. its working fine. The problem is that it is installed in usr/local/bin while I wanted it to be in usr/bin. besides I wanted python3 to point to python3.7 so I ran the following command sudo update-alternatives --config python3 and it said that there is no alternative for python3. Besides when I downloaded python3.7,and I unknowingly unzipped it in home directory. Now the whole python directory is in my home directory, so does that mean , whenever I make any changes like installing a library (eg. matplotlib) it will be installed directly in home/python3.7/lib.

2
  • 1
    It still depends on how you install it. If mathplotlib can use the libraries depends on your libpath and possible other environment variables required by mathplotlib. If you don't require special compilation/installation options, and the package is not available in any repository. I would first try to install it from a launchpad publish ppa like this one for python 3.7, rather than compiling it. launchpad.net/~jonathonf/+archive/ubuntu/python-3.7
    – jringoot
    Sep 24 '19 at 5:31
  • since I have already compiled it, I should go with it anyway. how can I make python3 point to python3.7 that is present in usr/local/bin. Sep 24 '19 at 7:05
0

While python is not rly integrated with dpkgs alternatives solution, you can change the link for python in /usr/bin

~$ ls -lt /usr/bin/python
lrwxrwxrwx 1 root root 7 márc   4  2019 /usr/bin/python -> python2
~$ ls -lt /usr/bin/python3
lrwxrwxrwx 1 root root 18 szept 24 08:49 /usr/bin/python3 -> python3.5
~$ sudo ln -fs /usr/local/bin/python3.7 /usr/bin/python3

This is the fast and easy way.

If you add the source repository of 18.04, you may do apt-get source python and build your own python package. This will replace the installed python3.5, cause the package name is python3.

Another alternative to just install 3.7 from here:

https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa

Something like that:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get install python3.7

This will also wipes your python 3.5 for the same reason.

1
  • hey thanks ! I ran the commands to change the link for python in /usr/bin, But I didn't quit understand what happened there. Did I delete any files by that command or something ? also what happened to python3.5, because earlier python3 would run python3.5. Sep 24 '19 at 15:58

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.