在 Ubuntu 16.04 LTS 上安装 Python 3.6.0
2017-07-08 17:30
531 查看
原文连接:https://segmentfault.com/a/1190000007912666
最近 Python 3 发布了新版本 Python 3.6.0,好像又加入了不少黑魔法!~
由于暂时不能使用 apt-get 的方式安装 Python 3.6,所以还是直接编译源码安装吧。
官网上提供了 Mac 和 Windows 上的安装包和 Linux 上安装需要的源码。
https://www.python.org/downlo…
安装
[plain] view plain copy print?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
[plain] view plain copy print?
python3.6 --version </span></span></li><li class=""><span>Python 3.6.0 </span></li></ol><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre code_snippet_id="2074801" snippet_file_name="blog_20161226_2_606225" name="code" class="plain" style="display: none;"> python3.6 –version
Python 3.6.0测试几个新的语法特性:
1
[plain] view plain copy print?
# Formatted string literals
>>> name = ‘Ray’
>>> f”Hello {name}.”
‘Hello Ray.’
效果相当于
[html] view plain copy print?
>>> name = ‘Ray’
>>> “Hello {name}.”.format(name=name)
‘Hello Ray.’
2
[plain] view plain copy print?
# Underscores in Numeric Literals
>>> a = 1_000_000_000_000_000
>>> a
1000000000000000
>>> ’{:_}’.format(1000000)
‘1_000_000”1_000_000’
[plain] view plain copy print?
# 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>]
第一次编译安装之后,有可能会发现输入python3.6 之后,方向键失效。
原因是 readline 库没有安装。
解决方式:
安装 readline 库
[plain] view plain copy print?
sudo apt-get install libreadline-dev
安装之后,再将 python 重新编译安装一次
[plain] view plain copy print?
cd Python-3.6.0 ./configure make sudo make install
最近 Python 3 发布了新版本 Python 3.6.0,好像又加入了不少黑魔法!~
由于暂时不能使用 apt-get 的方式安装 Python 3.6,所以还是直接编译源码安装吧。
官网上提供了 Mac 和 Windows 上的安装包和 Linux 上安装需要的源码。
https://www.python.org/downlo…
安装
[plain] view plain copy print?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
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测试
[plain] view plain copy print?
python3.6 --version </span></span></li><li class=""><span>Python 3.6.0 </span></li></ol><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre code_snippet_id="2074801" snippet_file_name="blog_20161226_2_606225" name="code" class="plain" style="display: none;"> python3.6 –version
Python 3.6.0测试几个新的语法特性:
1
[plain] view plain copy print?
# Formatted string literals
>>> name = ‘Ray’
>>> f”Hello {name}.”
‘Hello Ray.’
# Formatted string literals >>> name = 'Ray' >>> f"Hello {name}." 'Hello Ray.'
效果相当于
[html] view plain copy print?
>>> name = ‘Ray’
>>> “Hello {name}.”.format(name=name)
‘Hello Ray.’
>>> name = 'Ray' >>> "Hello {name}.".format(name= baf5 name) 'Hello Ray.'
2
[plain] view plain copy print?
# Underscores in Numeric Literals
>>> a = 1_000_000_000_000_000
>>> a
1000000000000000
>>> ’{:_}’.format(1000000)
‘1_000_000”1_000_000’
# Underscores in Numeric Literals >>> a = 1_000_000_000_000_000 >>> a 1000000000000000 >>> '{:_}'.format(1000000) '1_000_000''1_000_000'3
[plain] view plain copy print?
# 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>]
# 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 库
[plain] view plain copy print?
sudo apt-get install libreadline-dev
sudo apt-get install libreadline-dev
安装之后,再将 python 重新编译安装一次
[plain] view plain copy print?
cd Python-3.6.0 ./configure make sudo make install
cd Python-3.6.0 ./configure make sudo make install
相关文章推荐
- Ubuntu 16.04 LTS中源码安装Python 3.6.0的方法教程
- 在 Ubuntu 16.04 LTS 上安装 Python 3.6.0
- 在 Ubuntu 16.04 LTS 上安装 Python 3.6.0
- Ubuntu16.04LTS上安装Python3.6.3
- 安装Python 3.6 在Ubuntu 16.04 LTS 版本
- 安装Python 3.6 在Ubuntu 16.04 LTS 版本
- 安装Python 3.6 在Ubuntu 16.04 LTS 版本
- ubuntu14.04LTS下编译安装Open Babel和python语言绑定
- 如何在Windows 7系统下安装Ubuntu-Kylin 16.04 LTS 构成双系统
- 笔记本 安装 Ubuntu 16.04 LTS 开机死机
- 在 Ubuntu Server 16.04 LTS 上安装 LAMP
- 02. ubuntu 16.04 LTS 双系统安装之系统安装
- Ubuntu 16.04 LTS 一键安装VNC
- Ubuntu 16.04 LTS 下Nginx的编译安装与启动
- 12. ubuntu 16.04 LTS 安装Maven
- Ubuntu 16.04 LTS安装部署zookeeper-3.5.1-alpha
- 01. ubuntu 16.04 LTS 双系统安装之系统盘制作
- Ubuntu 16.04 LTS安装好之后需要做的15件事
- 06. ubuntu 16.04 LTS 安装搜狗输入法
- Ubuntu 16.04 LTS安装好之后需要做的15件事