Ubuntu 16.04 LTS source code installation Python 3.6.0 method tutorial

  • 2020-05-19 05:02:40
  • OfStack

The premise

The installation packages on Mac and Windows and the source code required for the installation on Linux are available on the official website.

Download address:

https://www.python.org/downloads/release/python-360/

The installation


wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
xz -d Python-3.6.0.tar.xz
tar -xvf Python-3.6.0.tar
cd Python-3.6.0
./configure
make
sudo make install

Testing:


$ python3.6 --version
Python 3.6.0

Test several new syntax features:

1.


# Formatted string literals
>>> name = 'Ray'     
>>> f"Hello {name}." 
'Hello Ray.'

Effect equivalent to


>>> name = 'Ray' 
>>> "Hello {name}.".format(name=name)
'Hello Ray.'

2.


# Underscores in Numeric Literals
>>> a = 1_000_000_000_000_000
>>> a
1000000000000000
>>> '{:_}'.format(1000000)
'1_000_000''1_000_000'

3.


# Enum.auto
>>> from enum import Enum, auto
>>> class Color(Enum):
... red = auto()
... blue = auto()
... green = auto()
... 
>>> list(Color)
[<Color.red: 1>, <Color.blue: 2>, <Color.green: 3>]

Tips

After the first build installation, you may find that the arrow keys fail after entering python3.6.

The reason is that the readline library is not installed.

Solution:

Install readline library


sudo apt-get install libreadline-dev

After installing, recompile python and install it again once.


cd Python-3.6.0
./configure
make
sudo make install

conclusion

The above is the whole content of this article, I hope the content of this article to your study or work can bring 1 definite help, if you have questions you can leave a message to communicate.


Related articles: