Python3安装

CentOS 6+系统默认安装的python版本是2.6.6,python2版本与python3还有有一些语法上的不一样。我们要把python升级到3版本,但是系统自带的旧版本python被系统很多其他软件环境依赖,所以不能直接卸载原来的2版本,所以我们重新安装一个3版本,将2版本的依赖保留。

1、下载Python安装包

源码包下载地址:https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz

2、安装源码编译器等工具:

[root@bigdata-pro03 softwares]# yum -y install gcc gcc-c++ autoconf automake make zlib zlib-devel

3、解压下好的源码包:

[root@bigdata-pro03 softwares]# tar -xzvf Python-3.6..tgz
[root@bigdata-pro03 softwares]# cd /opt/modules/Python-3.6./
[root@bigdata-pro03 Python-3.6.]# ls
aclocal.m4 configure Grammar Lib Makefile.pre.in Objects PCbuild Python Tools
config.guess configure.ac Include LICENSE Misc Parser Programs README
config.sub Doc install-sh Mac Modules PC pyconfig.h.in setup.py

4、编译安装包,指定安装路径:

注意:prefix参数用于指定将Python安装在新目录,这样不会覆盖原有的python。

./configure --prefix=/usr/local/python36
make && make install

5、修改系统默认的Python路径,因为默认的python指向2.6

mv /usr/bin/python /usr/bin/python-2.6.  

6、建立新的软连接,指向Python-3.6.0:

注:这里的python36是第4步指定的安装路径,python3.6是Python包里的可执行程序

ln -s /usr/local/python36/bin/python3. /usr/bin/python

7、因为yum是依赖python的,所以这里我们修改了默认的python,就要要修改yum,让其运行指向旧的版本:

vim /usr/bin/yum

将第一行“#!/usr/bin/python”

修改为“#!/usr/bin/python-2.6.”

8、测试按是否安装成功

[root@bigdata-pro02 Python-3.6.]# python
Python 3.6. (default, Nov , ::)
[GCC 4.4. (Red Hat 4.4.-)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

可以看到,已经成功安装Python3.6.0!

pip3安装

1、下载安装文件,使用python命令进行安装

wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
python get-pip.py

2、为pip建立软连接,使用pip命令安装requests模块

ln -s /usr/local/python36/bin/pip3. /usr/bin/pip
pip -V
pip install requests

[root@bigdata-pro03 gcc-build-9.2.]# pip

Usage:
pip <command> [options] Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
debug Show information useful for debugging.
help Show help for commands. General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be used up to times (corresponding to WARNING, ERROR,
and CRITICAL logging levels).
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should attempt (default times).
--timeout <sec> Set the socket timeout (default seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
--trusted-host <hostname> Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file containing the private key and the certificate in PEM
format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new version of pip is available for download.
Implied with --no-index.
--no-color Suppress colored output

到此,Centos系统下的Python3环境就搭建完成了!

centos6安装Python3环境的更多相关文章

  1. CentOS安装python3环境

    CentOS7.4安装python3环境 (Python 3.8.1) (stable version, Dec.18, 2019) # .从官网下载Python - Dec. , [stable v ...

  2. Mac 10.12下安装python3环境

    python3感觉用虚拟环境会比较好操作一些,也不用直接卸载python2. 一.基于brew快速安装 # 安装python3 brew install python3 # 安装pip(好像3自带pi ...

  3. Linux服务器超简单安装Python3环境、Ipython、Jupyter、virtualenv、virtualenvwrapper教程全在这了

    一.网卡配置 vim /etc/sysconfig/network-scripts/ifcfg-ens33 ONBOOT='yes' 二.更换Linux语言环境 1.修改配置文件 vim /etc/l ...

  4. centos7.4上安装python3环境的坑

    前言:为了将爬虫项目布置到服务器上,才有了今天这一下午的坑,必须记录 不要动现有的python2环境!不要动现有的python2环境!不要动现有的python2环境! 解压 tar -xvf Pyth ...

  5. 大数据学习之路-Centos6安装python3.5

    Centos 6.8安装python3.5.2 因为学习所需,需要用到python3.x的环境,目前Linux系统默认的版本都是python2.x的,还有一些自带的工具需要用到python2.6版本, ...

  6. Linux下安装python3环境搭建

    Linux下python3环境搭建 Linux安装软件有哪些方式? rpm软件包 手动安装 拒绝此方式 需要手动解决依赖关系 yum自动化安装 自动处理依赖关系 非常好用 源代码编译安装,可自定义的功 ...

  7. CentOS下安装python3环境及pypy环境

    安装前基础环境 1. win7虚拟机CentOS7.6系统 2. 网络环境通过NAT方式 3. 已经配置到yum仓库并系统自带有python2.7 安装前准备 1. python3.6.5源码包:ht ...

  8. centos6安装python3.4和pip3

    在安装了epel源的情况下,直接yum就可以安装python3.4 yum install python34 -ypython3 --version 没有自带pip3,从官网安装 wget --no- ...

  9. centos 7.6安装python3环境

    Centos7安装Python3的方法   由于centos7原本就安装了Python2,而且这个Python2不能被删除,因为有很多系统命令,比如yum都要用到. [root@VM_105_217_ ...

随机推荐

  1. vmware vSphere Data Protection 6.1--------2-初始化

    一.简介 安装完vdp接下来就是部署初始化了 安装篇请参考:vmware vSphere Data Protection 6.1部署 二.开始初始化 登陆https://192.168.216.200 ...

  2. 第4章 JIT编译器

    4.1 JIT概览 语言根据执行的方式不同分为编译型语言和解释型语言.以C++为代表的编译型语言在执行前需要编译成机器码,不同的CPU需要不同的编译器,编译成功后在同一台机器不需再次编译.以Pytho ...

  3. Powershell学习笔记:(一)、初识Powershell

    什么是Powershell? MSDN上的说明是:PowerShell 是构建于 .NET 上基于任务的命令行 shell 和脚本语言. PowerShell 可帮助系统管理员和高级用户快速自动执行用 ...

  4. 淘宝图片指纹匹配功能c#实现

    #region 生成图片及图片比较 public String GetHash(Image SourceImg) { Image image = ReduceSize(SourceImg); Byte ...

  5. [NOIP11.1模拟赛]补番报告

    Preface 昨天开始补某科学的超电磁炮S 感觉今天就好了点,炮姐赛高 T1 一开始一直想欧拉定理&ex欧拉定理,结果估计70分,数组开小了GG,看了正解发现是我学傻了 T2 一看就是数据结 ...

  6. print函数用法总结

    输出print函数总结: 1,字符串和数字类型 2,变量(数值,布尔,列表,字典) 3,格式化输出 格式化输出总结: (1)%:标记转换说明符的开始 (2)转换标志: - 表示左对齐:+ 表示在转换值 ...

  7. ElementUI+命名视图实现复杂顶部和左侧导航栏

    在了解了命名视图的用途后,发现用命名视图来实现复杂导航更加省力.更多知识请参考这里 这里只说明重要配置内容,其他内容配置请参考上一篇初始版本: ElementUI 复杂顶部和左侧导航栏实现 或参考文末 ...

  8. laravel管理模型插入

    post控制器public function comment(Post $post,Request $request){ try{ if(empty($request->content)){ E ...

  9. springboot系列(十)springboot整合shiro实现登录认证

    关于shiro的概念和知识本篇不做详细介绍,但是shiro的概念还是需要做做功课的要不无法理解它的运作原理就无法理解使用shiro: 本篇主要讲解如何使用shiro实现登录认证,下篇讲解使用shiro ...

  10. java - day019 - 数据库

    https://www.cnblogs.com/myxq666/p/7787744.html Mac 安装MySQL步骤 什么是数据库 数据库: 英文名称Database ,简称 DB 数据库是按照数 ...