Home > Backend Development > Python Tutorial > Tutorial on how to install Python 3.6.0 from source in Ubuntu 16.04 LTS

Tutorial on how to install Python 3.6.0 from source in Ubuntu 16.04 LTS

高洛峰
Release: 2017-01-10 13:14:22
Original
1883 people have browsed it

Premise

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

The download address is as follows:

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

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
Copy after login

Test:

$ python3.6 --version
Python 3.6.0
Copy after login

Test several new grammatical features:

1.

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

The effect is equivalent to

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

2.

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

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>]
Copy after login

Tips

After compiling and installing for the first time, you may find that after entering python3.6, the direction keys become invalid.

The reason is that the readline library is not installed.

Solution:

Install readline library

sudo apt-get install libreadline-dev
Copy after login

After installation, recompile and install python again.

cd Python-3.6.0
./configure
make
sudo make install
Copy after login

Summary

The above is the entire content of this article. I hope the content of this article can bring some help to everyone's study or work. If you have any questions, you can leave a message to communicate.

For more tutorials on how to install Python 3.6.0 from source code in Ubuntu 16.04 LTS, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template