CentOS 7 下Python3.6和Pip3安装实践

原创 陈宝佳  2018-10-01 13:46  阅读 67 次 评论 0 条
行云管家,新手有礼

一、安装python3.6

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

https://www.python.org/downloads/

mkdir -p /application/tools/

cd /application/tools/

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

3、安装python3

创建目录:

mkdir -p /usr/local/python3

解压下载好的Python-3.x.x.tgz包

tar -xvf Python-3.6.5.tgz 

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

cd Python-3.6.5
./configure --prefix=/usr/local/python3

make install

make && make install

5.建立python3 和 pip3的软链

rm -fr /usr/bin/python

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

rm -fr /usr/bin/pip

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip

检查Python3及pip3是否正常可用:

[root@beatz bin]# python -V
Python 3.6.5


[root@beatz bin]# pip -V
pip 9.0.3 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)


# 使用Pip 安装 requests
[root@beatz bin]# pip install requests



# 测试是否可用
[root@beatz bin]# python 
Python 3.6.5 (default, Sep 28 2018, 11:34:44) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests     # 没报错,证明Requests安装成功

(完)

本文地址:https://www.cloudbility.com/club/8334.html
关注我们:请关注一下我们的微信公众号:扫描二维码,公众号:cloudbility
版权声明:本文为原创文章,版权归 陈宝佳 所有,欢迎分享本文,转载请保留出处!

发表评论


表情