?、源码安装
????????1.?安装依赖软件包
[root@localhost ~]# yum groupinstall "Development Tools" -y
[root@localhost ~]# yum -y install zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel libffi-devel
????????2.?下载源码包
方法一:
百度网盘:链接: https://pan.baidu.com/s/1np6Faq9IvtCvALMrf63-Ow?pwd=wxtk 提取码: wxtk
方法二:
[root@localhost ~]# wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz
#直接下载
????????3.?解压安装
[root@localhost ~]# tar -xf Python-3.7.6.tar.xz
[root@localhost ~]# cd Python-3.7.6
????????4.?修改配置信息
[root@localhost Python-3.7.6]# sed -ri 's/^#readline/readline/' Modules/Setup.dist
[root@localhost Python-3.7.6]# sed -ri 's/^#(SSL=)/\1/' Modules/Setup.dist
[root@localhost Python-3.7.6]# sed -ri 's/^#(_ssl)/\1/' Modules/Setup.dist
[root@localhost Python-3.7.6]# sed -ri 's/^#([\t]*-DUSE)/\1/' Modules/Setup.dist
[root@localhost Python-3.7.6]# sed -ri 's/^#([\t]*-L\$\(SSL\))/\1/' Modules/Setup.dist
#去掉??的注释
????????5.?开始编译安装
[root@localhost Python-3.7.6]# ./configure --enable-shared
[root@localhost Python-3.7.6]# make -j 2 && make install # -j 当前主机的 cpu 核?数
?、 配置环境?
[root@192 ~]# cmd1='export LD_LIBRARY_PATH='
[root@192 ~]# cmd2='$LD_LIBRARY_PATH:/usr/local/lib'
[root@192 ~]# file="/etc/profile.d/python3_lib.sh"
[root@192 ~]# echo "${cmd1}${cmd2}" >$file
[root@192 ~]# path="/usr/local/lib"
[root@192 ~]# file2="/etc/ld.so.conf.d/python3.conf"
[root@192 ~]# echo ${path} > $file2
[root@192 ~]# ldconfig
[root@192 ~]# source /etc/profile
三、 测试安装?
????????1.?测试?python3
[root@192 Python-3.7.6]# python3 -V
Python 3.7.6
????????2.?测试?pip3
[root@192 Python-3.7.6]# pip3 -V
pip 19.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
#是?于存放 安装的第三?模块的
四、 配置使?本地的源安装第三?模块
????????1.?在当前?户的家?录下创建?个隐藏的?录?.pip
[root@192 ~]# mkdir ~/.pip
????????2.写?国内的源
[root@192 ~]# echo '[global]' >> ~/.pip/pip.conf
[root@192 ~]# c1="index-url=https://"
[root@192 ~]# c2="mirrors.aliyun.com/pypi/simple"
[root@192 ~]# echo "${c1}${c2}" >> ~/.pip/pip.conf
????????3.?测试配置正确??
[root@192 ~]# pip3 install ipython
#安装?个增强版的解释器 ipython ?于测试
?
?
?
?
?
?
?
?