zoukankan      html  css  js  c++  java
  • Linux服务器安装Python3.7

    Linux 安装 Python3.7

     

    1.安装依赖包

    yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel gcc

    2.下载Python3.7源码

    1) 下载
    # wget http://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
    2)解压
    # tar -xvf Python-3.7.1.tar.xz && cd Python-3.7.1/

    3.执行配置文件,编译,编译安装

    # ./configure --prefix=/usr/local/python37
    # make && make install

    安装完成没有提示错误便安装成功了

    4.建立软连接

    # mv /usr/bin/python /usr/bin/python_bak
    # ln -s /usr/local/python37/bin/python3.7 /usr/bin/python
    
    # ln -s /usr/local/python37/bin/pip3.7 /usr/bin/pip

    5.测试Python是否可用

    复制代码
    # python
    Python 3.7.1 (default, Jan 14 2019, 10:30:01) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print("hello world!")
    hello world!
    >>> exit()
    
    # pip  --version
    pip 10.0.1 from /usr/local/python37/lib/python3.7/site-packages/pip (python 3.7)
    复制代码

    注:

    安装完之后可能导致yum不能用,报错为:

    # yum -y install redis 
      File "/usr/bin/yum", line 30
        except KeyboardInterrupt, e:
                                ^
    SyntaxError: invalid syntax

    解决办法:

    # vi /usr/bin/yum  和 /usr/libexec/urlgrabber-ext-down

    将第一行"#!/usr/bin/python" 改为 "#!/usr/bin/python2.7"即可。

  • 相关阅读:
    1022.游船出租
    1021.统计字符
    1020.最小长方形
    1017.还是畅通工程
    1019.简单计算器
    1015.还是A+B
    1014.排名
    1013.开门人和关门人
    1011.最大连续子序列
    1009.二叉搜索树
  • 原文地址:https://www.cnblogs.com/tangda/p/14096996.html
Copyright © 2011-2022 走看看