Update python on linux 2.7 to 3.5

So, I updated python using the following instructions:

sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-devlibsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev 

then

 cd ~/Downloads wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz tar -xvf Python-3.5.0.tgz cd Python-3.5.0 

then

 ./configure sudo make install python3.5 Python 3.5.0 (default, Oct 3 2015, 03:16:42) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 

and it worked, but when I closed the terminal and wrote python -v it still remains python 2.7 and still gets errors executing code using standard v3 + libraries.

How to make it work like 3.5?

+5
source share
4 answers

You still have Python 2 installed, and the python command is still configured to invoke this version by default. Try running the scripts as follows:

 python3 yourscriptname.py 

In / usr / bin /, "python" is actually a symlink to python2.7. If you prefer not to type 3 at the end whenever you use python, change this symlink to point to python3 instead. Then python will run Python 3.5, and you can use python2.7 or just python2 to run Python 2.7 scripts.

+4
source

// install python 3.6

 sudo add-apt-repository ppa:jonathonf/python-3.6 sudo apt update sudo apt install python3.6 

// change python by default

 sudo rm /usr/bin/python sudo ln -s /usr/bin/python3 /usr/bin/python 

// default view

  python -V 
+13
source

Perhaps you just destroyed the python system installation by doing

 sudo make install 

This is set by default! And perhaps you will rewrite something that your Linux distribution will work correctly. Never do sudo make install unless you know where the resulting material goes. In the case of Python, you should have done

 sudo make altinstall 

to install it next to python by default, but it is best to install and use the python version through the distribution package manager.

+2
source

I read that changing global python to 3.5 can cause some problems so I install the build commands in geany for python3 and I can still run scripts from the outside by typing python3 xxx.py and now it’s convenient

+1
source

Source: https://habr.com/ru/post/1263286/


All Articles