Linux环境自带了Python 2.x版本,但是如果要更新到3.x的版本,可以在Python的官方网站下载Python的源代码并通过源代码构建安装的方式进行安装,具体的步骤如下所示。

1. 安装依赖库(因为没有这些依赖库可能在源代码构件安装时因为缺失底层依赖库而失败)
yum groupinstall 'Development Tools'
yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

  

2. 下载Python源代码并解压缩到指定目录
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
tar zxvf Python-3.6.5.tgz

 

3. 编译安装

加上--enable-optimizations时间会变的很长

./configure --prefix=/usr/local/python3.6.5 --enable-optimizations
make
make install

  

4. 建立软链接
ln -s /usr/local/python3.6.5/bin/python3 /usr/bin/python3
ln -s /usr/local/python3.6.5/bin/pip3 /usr/bin/pip3

  

5. 修改国内的pip源

常见件的国内源

清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/

  

 
临时更改方法   在使用pip时加上-i参数即可
pip install -i http://mirrors.aliyun.com/pypi/simple/ flask
永久修改的方法
mkdir -p ~/.pip/
vim ~/.pip/pip.conf
[global]
index-url = https://mirrors.aliyun.com/pypi/simple
[install]
trusted-host = mirrors.aliyun.com
修改pip/setup.py的源
vim ~/.pydistutils.cfg
[easy_install]
index_url = http://mirrors.aliyun.com/pypi/simple 

阿里云提供的脚本修改:

wget http://image-offline.oss-cn-hangzhou.aliyuncs.com/fix/fix_pypi.sh
bash fix_pypi.sh "mirrors.aliyuncs.com"

Centos升级Python及pip的更多相关文章

  1. 【Linux】CentOS下升级Python和Pip版本全自动化py脚本

    [Linux]CentOS下升级Python和Pip版本全自动化py脚本 CentOS7.6自带py2.7和py3.6 想要安装其它版本的话就要自己重新下载和编译py其它版本并且配置环境,主要是软链接 ...

  2. Centos 升级 python

    昨天把redmine的测试环境给搞Over了,想了下,干脆直接把环境给整成docker化的,配置环境的时候,安装docker-compose需要python2.7支持. CentOS 6 系统默认 P ...

  3. 【转】Centos升级Python 2.7.12并安装pip、ipython

    Centos系统一般默认就安装有Python2.6.6版本,不少软件需要2.7以上的,通过包管理工具安装不了最新的版本,通过源码编译可以方便安装指定版本,只需要把下面版本的数字换成你想要的版本号. 1 ...

  4. centos 升级 python后 python-setuptools pip 安装依赖报错

    解决办法: $ wget https://svn.apache.org/repos/asf/oodt/tools/oodtsite.publisher/trunk/distribute_setup.p ...

  5. Centos升级Python 2.7并安装pip、ipython

    https://www.cnblogs.com/technologylife/p/6242115.html

  6. liunx CentOS 升级Python版本

    CentOS python版本是V2.6.6,升级3.4.3. 1.下载 安装包:wget http://www.python.org/ftp/python/3.4.3/Python-3.4.3.tg ...

  7. centos升级python到2.7

    最近在阿里云租了一个云主机,打算部署自己的个人网站,但是centos系统的默认Python是2.6版本,打算升级到2.7.3! 查看python的版本 #python  -V Python 2.6.6 ...

  8. k8s构建镜像-基于centos的python环境+pip

    FROM centos:7.4.1708 #维护者信息MAINTAINER by icdss # 标签LABEL version="1.0" # 安装依赖RUN yum -y up ...

  9. CentOS升级Python的方法

    centOS内核版本为:3.10.101-1.el6.elrepo.x86_64 1,下载Python安装包 wget http://www.python.org/ftp/python/2.7.6/P ...

随机推荐

  1. python:用json把字典序列化到文件中

    #写程序最好是dump一次和load一次,可以存好几个文件 import json info={'name':'Tom', 'age':'12', 'job':'work',} f=open('fil ...

  2. java下载安装,环境变量,hello world

    1.Java下载安装 网址:http://java.sun.com/javase/downloads/index.jsp win7 64位选择jdk-8u11-windows-x64.exe. 2.环 ...

  3. PL/SQL注册码

    code:j6stndb9tk72xfbhbqczcdqnjd8lyj466n number:882851 ps:xs374ca

  4. 网页撤销后ubuntu本地撤销

    git reset --hard <commit_id> 回到上一个commit: 之后再    git reset --hard :

  5. Android mvp模式、mvvm模式

    MVC和MVP的区别2007年08月08日 星期三 上午 09:23 MVC和MVP到底有什么区别呢? 从这幅图可以看到,我们可以看到在MVC里,View是可以直接访问Model的!从而,View里会 ...

  6. Prompt isNaN 数组 function DOM window.open/close/location/history

    1.prompt的利用 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Defa ...

  7. HTML DOM事件

    HTML DOM事件 1.HTML事件包括: (1)当用户点击鼠标时: (2)当页面已加载时: (3)当图像已加载时: (4)当鼠标移动到元素上时: (5)当输入字段被改变时: (6)当提交HTML表 ...

  8. 在HTML5规范中div中读取预存的data-[key]值

    HTML 代码: <div id="div_test" data-test="this is test" ></div> jQuery ...

  9. jQuery 判断页面元素是否存在

    if ( $("#someID").length > 0 ) {  } 根据JavaScript的经验,尝试用$("#someID") != " ...

  10. 我的android学习经历28

    一道题目关于Layout_weight: 当前屏幕的大小为430,有左右两个控件,未分配权重之前都是300,左控件的权重是3,右控件的权重是2,请计算左右两个控件的宽度大小是多少? 解: 当前屏幕剩余 ...