我是靠谱客的博主 生动水杯,这篇文章主要介绍Ubuntu 16.04 LTS中源码安装Python 3.6.0的方法教程,现在分享给大家,希望可以做个参考。

前提

官网上提供了 Mac 和 Windows 上的安装包和 Linux 上安装需要的源码。

下载地址如下:

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

安装

复制代码
1
2
3
4
5
6
7
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

测试:

复制代码
1
2
$ python3.6 --version Python 3.6.0

测试几个新的语法特性:

1.

复制代码
1
2
3
4
# Formatted string literals >>> name = 'Ray' >>> f"Hello {name}." 'Hello Ray.'

效果相当于

复制代码
1
2
3
>>> name = 'Ray' >>> "Hello {name}.".format(name=name) 'Hello Ray.'

2.

复制代码
1
2
3
4
5
6
# Underscores in Numeric Literals >>> a = 1_000_000_000_000_000 >>> a 1000000000000000 >>> '{:_}'.format(1000000) '1_000_000''1_000_000'

3.

复制代码
1
2
3
4
5
6
7
8
9
# 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

第一次编译安装之后,有可能会发现输入python3.6 之后,方向键失效。

原因是 readline 库没有安装。

解决方式:

安装 readline 库

复制代码
1
sudo apt-get install libreadline-dev

安装之后,再将 python 重新编译安装一次。

复制代码
1
2
3
4
cd Python-3.6.0 ./configure make sudo make install

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。

最后

以上就是生动水杯最近收集整理的关于Ubuntu 16.04 LTS中源码安装Python 3.6.0的方法教程的全部内容,更多相关Ubuntu内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(152)

评论列表共有 0 条评论

立即
投稿
返回
顶部