系统相关
首页 > 系统相关> > CentOS7塔建python3

CentOS7塔建python3

作者:互联网

python的下载地址:http://www.python.org/downloads/source/

1.点击红圈下载

2. 安装处理编译源文件包和依赖包,上传python源包

yum install gcc gcc-c++ make cmake      #安装处理编译源文件包

yum install zlib zlib-devel  bzip2 bzip2-devel   ncurses ncurses-devel  readline readline-devel openssl openssl-devel  openssl-static  xz  xz-devel  sqlite sqlite-devel  gdbm gdbm-devel  tk tk-devel  db4-devel   libffi-devel        #安装python的依赖包

[root@localhost ~]# rz                   #连接Xshell上传python源包

[root@localhost ~]# ls -lh Python-3.7.3.tgz                    #查看是否上传成功
-rw-r--r--. 1 root root 22M 5月   1 11:28 Python-3.7.3.tgz

3.解压python3源包,创建空目录存放python3

[root@localhost ~]# tar -zxvf Python-3.7.3.tgz        #解压python源包

[root@localhost ~]# ls Python-3.7.3                   #查看python源包的内容
aclocal.m4           configure     Include     m4               Modules  PCbuild        README.rst
CODE_OF_CONDUCT.rst  configure.ac  install-sh  Mac              Objects  Programs       setup.py
config.guess         Doc           Lib         Makefile.pre.in  Parser   pyconfig.h.in  Tools
config.sub           Grammar       LICENSE     Misc             PC       Python


[root@localhost ~]# cd Python-3.7.3/                   #切换到源包的里面    
[root@localhost Python-3.7.3]# 


[root@localhost Python-3.7.3]# mkdir /usr/local/python3       #创建空目录存放python3

4.检查python3包和存放python3包,编译python3包和安装python3包

[root@localhost Python-3.7.3]# ./configure --prefix=/usr/local/python3   #检查安装包的依赖关系是否正确,--prefix=FilePath(存放文件的路径)-->表示把所有文件放到指定的路径,而不是默认路径

[root@localhost Python-3.7.3]# make            #编译python3
Python build finished successfully!            #显示这个就行了,编译就成功


[root@localhost Python-3.7.3]# make install    #安装python3
Installing collected packages: setuptools, pip
Successfully installed pip-19.0.3 setuptools-40.8.0      #显示这个就行了,安装就成功


[root@localhost ~]# ls /usr/local/python3/                #查看python3的内容
bin  include  lib  share

5.创建软链接,相当于Windows下的快捷方式

[root@localhost ~]# ln -s /usr/local/python3/bin/python3.7  /usr/bin/python3   #创建python3软链接
[root@localhost ~]# ln -s /usr/local/python3/bin/pip3.7     /usr/bin/pip3      #创建pip3软链接

6.检验是否可以用,如下就塔建成功,可以用

[root@localhost ~]# python3                                    #启动python3
Python 3.7.3 (default, May  1 2019, 20:20:54) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello world!')                                     
hello world!



[root@localhost ~]# pip3 --version                              #查看pip3版本
pip 19.0.3 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)

参考Linux公社的文章: http://www.linuxidc.com/Linux/2018-07/153286.htm

 

 

 

 

 

 

标签:塔建,Python,devel,CentOS7,3.7,python3,root,localhost
来源: https://blog.csdn.net/qq_41709494/article/details/89738929