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.
>>> 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章