CentOS安装python3.6
下载Python安装包
cd /usr/local/src
编译时要提前装好gcc编译器和zlib zlib-devel
1、下载文件
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
2、解压
tar -zxvf Python-3.6.0.tgz
3、进入解压目录
cd Python-3.6.0
4、编译安装包
./configure --prefix=/usr/local/python make && make install
5、添加环境变量
echo PATH='/usr/local/python/bin/:$PATH' >> /etc/profile
source /etc/profile
6、检查是否成功,执行下面代码
python3.6 Python 3.6.0 (default, Jun 1 2017, 14:01:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello word')
hello word
Python安装常见问题:
(1)configure: error: no acceptable C compiler found in $PATH
解决:yum install -y gcc
(2):zipimport.ZipImportError: can’t decompress data
解决:安装zlib zlib-devel
1、修改系统默认的Python路径,因为在终端中输入Python命令时默认是指向Python2.6.6
mv /usr/bin/python /usr/bin/python-2.6.6
2、建立新的软连接,指向Python-3.6.0
ln -s /usr/local/python/bin/python3.6 /usr/bin/python
3、因为yum是依赖python的,所以这里我们修改了默认的python,就要要修改yum,让其运行指向旧的版本:
vi /usr/bin/yum
将第一行中的“#!/usr/bin/python” 修改为“#!/usr/bin/python-2.6.6”,保存即可
4、打开一个新的终端,通过python命令进入python环境,可以看到已经指向了我们新安装的python3.6.0:
[centos65_1@localhost:~]$ python
Python 3.6.0 (default, Jul 30 2016, 19:40:32)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
5、Centos中Python升级为3.X时yum出现except OSError, e: ^ SyntaxError: invalid syntax问题
CentOS 7升级Python到3.6后,需要在/usr/bin/python创建了一个指向Python 3的软连接,然后将/usr/bin/yum的顶部的:
!/usr/bin/python
改成了
!/usr/bin/python-2.7.5
后,运行yum,还是出现了以下错误:
[root@master ~]# yum -y groupinstall “X Window System”
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
解决方案:
(1). vim /usr/libexec/urlgrabber-ext-down
将/usr/bin/python改为/usr/bin/python-2.7.5。
(2). vim /usr/bin/yum-config-manager
解决办法同上: #!/usr/bin/python换成 #!/usr/bin/python-2.7.5
CentOS安装python3.6的更多相关文章
- Centos安装python3
安装环境 系统:阿里云服务器centos7.5系统 看见好多博客对centos安装python3的方式各不相同且都不完整,今天我来完整的演示安装python3 1.下载python3源码包 命令 wg ...
- CentOS 安装Python3.x常见问题
CentOS 6.x自带的Python版本是2.6,CentOS 7.x上自带的是2.7,我们要自己安装Python3.X,配置环境,不过一般安装过程不会一帆风顺,往往有些报错,在CentOS以及其他 ...
- 腾讯云centos安装python3.6和pip
不知道腾讯云的centos和阿里云的centos一不一样,反正两个云平台的Ubuntu系统是不一样的,照着同样的教程敲,往往掉坑里. 安装一些centos依赖库: 这一步很关键,很多报错往往都因为少了 ...
- CentOS 安装Python3、pip3
https://ehlxr.me/2017/01/07/CentOS-7-%E5%AE%89%E8%A3%85-Python3%E3%80%81pip3/ CentOS 7 默认安装了 Python ...
- centos安装python3虚拟环境和python3安装
1.本文的系统命令一般会在语句前加上#号,以区分系统命令及其他内容.输入命令时,无需输入#号. # yum install vim 2.本文系统输出的信息,会在前面加上>>号. # whi ...
- CentOS 安装 Python3
CentOS 7 默认安装 python 2.7.5 如图: 开始安装Python 3.6.3 1.下载Python3.6.3包: 拉到最下面,找到对应的包.复制下载链接地址: wget https ...
- centOS安装python3 以及解决 导入ssl包出错的问题
参考: https://www.cnblogs.com/mqxs/p/9103031.html https://www.cnblogs.com/cerutodog/p/9908574.html 确认环 ...
- Linux基础:CentOS安装python3.7
1.下载python3 wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz 2.解压 [root@mycentos ~]# ta ...
- centos 安装python3与Python2并存,并解决"smtplib" object has no attribute 'SMTP_SSL'的错误
1.需要先安装python3依赖的包yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readli ...
- [亲测!超级简单] Centos 安装Python3.6环境
配置好Python3.6和pip3安装EPEL和IUS软件源 yum install epel-release -y yum install https://centos7.iuscommunity. ...
随机推荐
- socket,模拟服务器、客户端通信
服务器代码: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;u ...
- PHP一些常用的正则表达式分享给大家
一.校验数字的表达式 1 数字:^[0-9]*$2 n位的数字:^\d{n}$3 至少n位的数字:^\d{n,}$4 m-n位的数字:^\d{m,n}$5 零和非零开头的数字:^(0|[1-9][0- ...
- vue中使用provide和inject刷新当前路由(页面)
1.场景 在处理列表时,常常有删除一条数据或者新增数据之后需要重新刷新当前页面的需求. 2.遇到的问题 1. 用vue-router重新路由到当前页面,页面是不进行刷新的 2.采用window.rel ...
- Dynamics CRM项目实例之九:CRM 2015的产品中的捆绑销售
关注本人微信和易信公众号: 微软动态CRM专家罗勇,回复140或者20150112可方便获取本文,同时可以在第一时间得到我发布的最新的博文信息,follow me! 今天的博客主要是介绍Dy ...
- Navicat for MySQL破解版安装
https://pan.baidu.com/s/1OfFPvqrTqbUAC_Eqq2i0KA 提取码:jgep 点击第一个应用程序一路安装即可. 安装成功之后,再点击第二个应用程序PatchNavi ...
- Git源代码管理
一. 分支管理 使用 git 进行源代码管理,一般将某个项目的所有分支分为以下几条主线 1. Master 顾名思义,既然名字叫 Master ,那么该分支就是主分支的意思. master 分支永远是 ...
- The xp_cmdshell proxy account information cannot be retrieved or is invalid. Verify that the '##xp_cmdshell_proxy_account##' credential exists and contains valid information.
In one of our recent migrations, we got the following error when the client tried to fire xp_cmdshel ...
- EOS之hello智能合约解析
传送门: 柏链项目学院 EOS的智能合约与以太坊区别很大, EOS 的智能合约基于 WebAssembly(WASM) 技术执行用户生成的应用程序和代码.WASM是一项新兴的网络标准,得到了谷歌, ...
- Anaconda在Windows上安装不上原因
倒腾了一下午安装Anaconda,[所有程序]中只有一个Anaconda的目录,目录中只有一个anaconda prompt,最后发现是因为环境中原先就安装了Java环境,将之前安装的java环境卸载 ...
- mysql8.0.主从复制搭建
搭建主从数据库 一.准备两台以上对的数据库 数据库1(主服务器):192.168.2.2 数据库2(从服务器):192.168.2.4 1.1 配置主服务器 .在 /et ...