程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Linux Installation python3.10

編輯:Python

linux install python3.10

In terms of operation and maintenance , There are many scripts used , Some scripts use shell Writing will be tiring , use python It will be easier , because python There is a powerful class library , It can handle all kinds of environments well .

Let's demonstrate linux Installation on system python The process of :

1、 download python package :

Here we can download it directly from the official website :( Maybe the speed of opening the official website is a little slow .)python Official website

choice linux System :

Download the new in the stable version :

  • Here, because of the slow network speed , You can consider downloading to the local , After uploading to the server :
  • It can also be direct wget Command download , But wait patiently
# download python package 
wget https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz
# It's not installed here wget The partners , Sure yum Install 
yum install -y wget

2、 install python Related dependency packages :

yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

3、 Compilation and installation :

  • Note here : The original linux On the system python2 There is , Let's not delete him , otherwise yum And firewalls cannot be used .
# see python
python -V
Python 2.7.5
  • decompression python Source package :
tar -zxf Python-3.10.5.tgz
cd Python-3.10.5
./configure --prefix=/usr/local/python3/
  • Compilation and installation :
make && make install
  • Add environment variables :
#python
PATH=/usr/local/python3/bin:$PATH
# After the save , Refresh profile 
source /etc/profile
  • Add soft connection :

Add the execution file to /usr/bin Under the table of contents , Make it work globally
Before adding ,/usr/bin It's in the catalog python2 Version of the execution file

# Here we will introduce the original python Change your name 
mv /usr/bin/python /usr/bin/python.bak
# Then create a soft connection 
ls -n /usr/local/python3/bin/python3 /usr/bin/python
ls -n /usr/local/python3/bin/pip3 /usr/bin/pip
python -V
# The following will show :
Python 3.10.5

4、 Optimize :

because yum and firewall All depend on python, So change /usr/bin The executable files under will make them unavailable , You need to modify the configuration ;

  • modify yum The configuration file :
vi /usr/bin/yum
# Take the first line "#!/usr/bin/python" Change it to "#!/usr/bin/python2.7" that will do 
vi /usr/libexec/urlgrabber-ext-down
# Same thing here ,#!/usr/bin/python Change it to #!/usr/bin/python2.7
  • modify Firewalls To configure :
vi /usr/bin/firewall-cmd
# Take the first line "#!/usr/bin/python" Change it to "#!/usr/bin/python2.7"
vi /usr/sbin/firewalld
# Take the first line "#!/usr/bin/python" Change it to "#!/usr/bin/python2.7"

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved