我是靠谱客的博主 洁净白开水,这篇文章主要介绍centos7安装Python3,现在分享给大家,希望可以做个参考。

[root@node01 ~]# yum install yum-utils
[root@node01 ~]# yum install openssl-devel -y 
[root@node01 ~]# mkdir -p  /usr/local/python3
[root@node01 ~]# cd /usr/local/python3/
[root@node01 python3]# wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz
[root@node01 python3]# tar -zxvf Python-3.6.7.tgz
[root@node01 python3]# cd Python-3.6.7
[root@node01 python3.6.7]# ./configure --prefix=/usr/local/python3 --with-ssl 
[root@node01 python3.6.7]# make && make install
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.
[root@node01 python3.6.7]# cd ..
[root@node01 Python3]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@node01 Python3]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@node01 Python3]# python3 -V
Python 3.6.7
[root@node01 Python3]# python3
Python 3.6.7 (default, Mar  5 2020, 11:00:15) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

下面给centos的中Python添加环境变量,这样可以使用ipython

[root@node01 ~]# vim .bashrc 
alias python='/usr/bin/python3'
[root@node01 ~]# vim /etc/profile
##########
export PATH=$PATH:/usr/local/python3/bin
[root@node01 ~]# source /etc/profile
[root@node01]# ipython
/usr/local/python3/lib/python3.6/site-packages/IPython/core/history.py:226: UserWarning: IPython History requires SQLite, your history will not be saved
  warn("IPython History requires SQLite, your history will not be saved")
Python 3.6.7 (default, Mar  5 2020, 12:25:00) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: 
# 这样就是Pyhon3了
[root@node01 ~]# python
Python 3.6.7 (default, Mar  5 2020, 12:25:00) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

最后

以上就是洁净白开水最近收集整理的关于centos7安装Python3的全部内容,更多相关centos7安装Python3内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(80)

评论列表共有 0 条评论

立即
投稿
返回
顶部