python 3.64安装,升级gcc(版本过低安装错误),3.64gcc,1. 安装依赖环境 


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

2.下载Python3

wget ttp://mirrors.sohu.com/python/3.6.4/Python-3.6.4.tgz

3.安装python3

  我个人习惯安装在/usr/local/python3(具体安装位置看个人喜好)
  创建目录:mkdir -p /usr/local/python3

解压下载好的Python-3.x.x.tgz包(具体包名因你下载的Python具体版本不不同,如:我下载的是Python3.6.4.那我这里就是Python-3.6.4.tgz)

tar -zvxfPython-3.6.4.tgz

技术分享图片

  结果发现make失败

参考了文章发现gcc版本过低需要安装4.8.2以上

升级代码见下文,升级的是6.1版本

wget http://ftp.gnu.org/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.gztar -zvxf gcc-6.1.0.tar.gz --directory=/usr/local/cd /usr/local/gcc-6.1.0./contrib/download_prerequisitesmkdir build cd build ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib make -j4 #编译时间有点长 一个多小时make install

  

升级gcc过程报错处理

# 查看日志,搜索"error"cat config.log|grep # issue: configure: error: C++ compiler missing or inoperational# 没有C++编译器yum install gcc-c++# issue: conftest.cpp:11:2: error: #error -static-libstdc++ not implemented# 没有C,C++静态库yum install glibc-static libstdc++-static -y# 但报"No package libstdc++-static available",即没有-static-libstdc++源,问题仍存在。# "checking whether g++ accepts -static-libstdc++ -static-libgcc"时报出的,可忽略checking how to run the C++ preprocessor... /lib/cppconfigure: error: C++ preprocessor "/lib/cpp" fails sanity checkSee `config.log‘ for more details.        /lib/cpp fails sanity check的解决  在某些软件的时候,运行./configure 会报错,错误提示为:  configure: error: C++ preprocessor “/lib/cpp” fails sanity   check See `config.log’ for more details  解决办法:出现该情况是由于c++编译器的相关package没有安装,以root用户登陆,在终端上执行:  # yum install glibc-headers  # yum install gcc-c++

4、进入解压后的目录,编译安装。

    [[email protected] /]# tar -xzvf /usr/local/src/Python-3.6.4.tgz -C /usr/local/src/    [[email protected] /]# cd /usr/local/src/Python-3.6.4    [[email protected] Python-3.6.4]# ./configure --prefix=/usr/local/python3    [[email protected] Python-3.6.4]# make -j4    [[email protected] Python-3.6.4]# make install

5、添加Python命令到环境变量:

   [[email protected] /]# vi ~/.bash_profile    PATH=$PATH:$HOME/bin    改为:    PATH=$PATH:$HOME/bin:/usr/local/python3/bin
[[email protected] /]# source ~/.bash_profile

6、更改系统默认python版本为Python3.6

    [[email protected] /]# mv /usr/bin/python /usr/bin/python2.6    [[email protected] /]# ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
[[email protected] /]# python -V

解决python升级后,YUM不能正常工作的问题:

#vi /usr/bin/yum

将文件头部的   #!/usr/bin/python
  改成   #!/usr/bin/python2.6



python 3.64安装,升级gcc(版本过低安装错误)

评论关闭