gaojinguan 发表于 2018-8-11 06:03:36

python2.6.6升级python3.5.2-7835882

  以centos为例
  默认python版本为:
  python
  Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
   on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>>
  升级py 我们这边用的是较新的版本3.5
  一、下载及安装
  wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
  tar -zxvf Python-3.5.2.tgz
  cd Python-3.5.2
  mkdir /usr/local/python3
  ./configure --prefix=/usr/local/python3
  make && make install
  二、重命名老python版本,把新版本软连接到系统环境中
  mv /usr/bin/python /usr/bin/python_26
  ln -s /usr/local/python3/bin/python3 /usr/bin/python
  三、验证
  python
  Python 3.5.2 (default, Dec 29 2016, 16:34:53)
   on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>>
  # cat test.py
  import os
  print ('hello world')
  # python test.py
  hello world
  #
  报错处理:
  使用yum报错
  解决:
  # cp /usr/bin/yum /usr/bin/yum.backup_2016-12-30
  vim /usr/bin/yum
  #!/usr/bin/python    修改为:/usr/bin/python_2016-12-30
  cat /usr/bin/yum |grep /usr/bin/pyth
  #!/usr/bin/python2.6
页: [1]
查看完整版本: python2.6.6升级python3.5.2-7835882