Centos6.5 Python升级安装及遇到问题

安装步骤:
参考IDO老徐文章Linux下python安装升级步骤详解 | Python2 升级Python3

Linux下默认系统自带python2.X的版本,这个版本被系统很多程序所依赖,所以不建议删除,如果使用最新的Python3那么我们知道编译安装源码包和系统默认包之间是没有任何影响的,所以可以安装python3和python2共存.

Linux下查看Python安装路径、版本号

1.查看Python路径

whereis python
which python

2.查看安装的Python版本号

python -V


安装中遇到的问题及解决办法:

一)使用wget下载东西,提示没有安装wget程序库

因为最小化版本的centos是默认没有安装wget程序库的.
解决方法:
yum安装wget
yum -y install wget


二) 使用yum安装wget报错

Centos6.5 Python升级安装及遇到问题_第1张图片

网上搜索报错信息,是由于没有联网引起的。
解决方法:
方法一:
  1. 打开 vi /etc/sysconfig/network-scripts/ifcfg-eth0(每个机子都可能不一样,但格式会是“ifcfg-eth数字”),把ONBOOT=no,改为ONBOOT=yes
  2. 重启网络:service network restart
方法二:
  1. 打开 vi /etc/resolv.conf,增加 nameserver 8.8.8.8
  2. 重启网络: service network restart


三)配置安装路径时,报错

[root@local Python-3.3.0]# ./configure --prefix=/usr/local/python3
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/python3 ':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

从报错信息可以看出,缺少gcc编译环境。
解决方法:
yum安装gcc
yum -y install gcc

你可能感兴趣的:(Centos6.5 Python升级安装及遇到问题)