进入家目录: `cd ~`
`wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz`下载到本地
解压移动到/usr/lcoal下:tar -zxvf Python-3.6.3.tgz
mv Python-3.6.3 /usr/local/
安装依赖: 缺少其他依赖在这儿看yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
删掉旧python软连接rm -rf /usr/bin/python
尝试编译安装Python:
cd /usr/local/Python-3.6.3/
配置:./configure
编译:make
安装:make install
报错未找到合适的编译器:
configure: error: in `/usr/local/Python-3.6.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
解决:yum install gcc-c++
-bash: /usr/bin/yum: /usr/bin/python:bad interpreter no such file or dir
这是因为上面删了 python软连接, 而yum依赖python。所以这儿去修改yum 文件头调用python 改成 python2.7 就好了vim /usr/bin/yum
文件头调用修改:
!/usr/bin/python 改------>成 #!/usr/bin/python2.7
vim /usr/libexec/urlgrabber-ext-down
! /usr/bin/python2 改--------->成 #! /usr/bin/python2.7
重新执行:安装编译器yum install gcc-c++
再次执行编译/安装:
cd /usr/local/Python-3.6.3/
配置:./configure
编译:make
安装:make install
重新增加python软连接,连接到python3cd /usr/bin
ln -s /usr/local/bin/python3 python
执行 python -V 查看python版本python -V
成功
zipimport.ZipImportError: can’t decompress data; zlib not available
make: * [install] Error 1
- 解决:
就是缺少了zlib库,zlib not available 不可用
yum安装上即可:
yum -y install zlib*