在 Ubuntu 16.04 LTS 上安装 Python 3.6.0



原文连接:https://segmentfault.com/a/1190000007912666



最近 Python 3 发布了新版本 Python 3.6.0,好像又加入了不少黑魔法!~



由于暂时不能使用 apt-get 的方式安装 Python 3.6,所以还是直接编译源码安装吧。


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



https://www.python.org/downlo…

安装

  1. wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz  
  2. xz -d Python-3.6.0.tar.xz  
  3. tar -xvf  Python-3.6.0.tar  
  4. cd Python-3.6.0  
  5. ./configure  
  6. make  
  7. 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
测试

  1. &nbsp;python3.6&nbsp;--version&nbsp;&nbsp;</span></span></li><li class=""><span>Python&nbsp;3.6.0&nbsp;&nbsp;</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

    1. # Formatted string literals  
    2. >>> name = ‘Ray’                                      
    3. >>> f”Hello {name}.”         
    4. ‘Hello Ray.’  
    # Formatted string literals
    >>> name = 'Ray'                                    
    >>> f"Hello {name}."       
    'Hello Ray.'


    效果相当于

    1. >>> name = ‘Ray’         
    2. >>> “Hello {name}.”.format(name=name)  
    3. ‘Hello Ray.’  
    >>> name = 'Ray'       
    >>> "Hello {name}.".format(name=name)
    'Hello Ray.'

    2
    1. # Underscores in Numeric Literals  
    2. >>> a = 1_000_000_000_000_000  
    3. >>> a  
    4. 1000000000000000  
    5. >>> ’{:_}’.format(1000000)  
    6. ‘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

    1. # Enum.auto  
    2. >>> from enum import Enum, auto  
    3. >>> class Color(Enum):  
    4. …     red = auto()  
    5. …     blue = auto()  
    6. …     green = auto()  
    7. …   
    8. >>> list(Color)  
    9. [<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 库

    1. sudo apt-get install libreadline-dev  
    sudo apt-get install libreadline-dev


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


    1. cd Python-3.6.0  
    2. ./configure  
    3. make  
    4. sudo make install  
    cd Python-3.6.0
    ./configure
    make
    sudo make install


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值