centos7安装Python3

举报
毛利 发表于 2021/07/15 04:09:11 2021/07/15
【摘要】 [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 p...
[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()

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

下面给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.
>>> 


  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

文章来源: maoli.blog.csdn.net,作者:刘润森!,版权归原作者所有,如需转载,请联系作者。

原文链接:maoli.blog.csdn.net/article/details/104675023

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。