美文网首页
Python安装

Python安装

作者: jdzhangxin | 来源:发表于2018-06-27 12:43 被阅读19次

1. 简介

Python是一种解释型、面向对象、动态数据类型的高级程序设计语言。
Python由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年。

Python 源代码同样遵循 GPL(GNU General Public License)协议。现在主要有两个版本Python2、Python3,两者语法和使用上存在细微差异。

2. 安装

2.1 检查

  • 查看Python版本python -V或者python3 -V
  • 查看Python可执行文件位置which python或者which python3

2.2 自动安装

  • 查下yum源支持的Python安装版本yum search python
  • 安装yum install python版本号

2.3 手动安装

2.3.1 Linux手动安装

如果之前安装了有Python2,需要先备份mv /usr/bin/python /usr/bin/python2

  1. 下载安装包
    wget https://www.python.org/ftp/python/版本号/Python-版本号.tar.xz
    
  2. 安装依赖
    yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
    
  3. 解压
    tar -xvJf  Python-版本号.tar.xz
    
  4. 进入目录
    cd Python-版本号
    
  5. 配置
    ./configure prefix=/usr/local/python3
    
  6. 编译
    make
    
  7. 安装
    make install
    

可以添加软连接到执行目录下/usr/bin

ln -s /usr/local/python3/bin/python3 /usr/bin/python
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
  1. 修改yum的依赖
    yum是依赖于Python的,安装Python3后yum就没办法直接用了,需要直接指定修改yum中Python脚本的解释器才能使用。修改/usr/bin/yum/usr/bin/urlgrabber-ext-down两个文件的头文件,即将第一行#!/usr/bin/python 改为 #!/usr/bin/python2

2.3.2 Windows手动安装

相关文章

网友评论

      本文标题:Python安装

      本文链接:https://www.haomeiwen.com/subject/wqdbyftx.html