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

Operation and maintenance -python3 and python2 coexist

編輯:Python

python3 And python2 coexistence

  • Centos
  • kali

Centos


Linux python2 3 coexistence
whereis python
ll python*
download python3 Before my bag , You must first install the relevant dependent packages , For downloading and compiling python3:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
default centos7 Is not installed pip, To add epel Extended source
yum -y install epel-release
install pip
yum install python-pip
use pip loading wget
pip install wget
use wget download python3 The source package , Or download it yourself , Upload to the server and install , If the network is fast, you can install it directly
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
compile python3 Source package , decompression
xz -d Python-3.6.8.tar.xz tar -xf Python-3.6.8.tar
cd Python-3.6.8
./configure prefix=/usr/local/python3
make && make install
Installation dependency zlib、zlib-deve
yum install zlib zlib
yum install zlib zlib-devel
Add soft link , Back up the original link
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
13、 Test if the installation is successful
python -V
change yum To configure , Because it uses python2 To perform , Otherwise, it will lead to yum Can't be used normally
- I am using
sudo ln -s /usr/bin/python2.x /usr/bin/python
among x Is your python edition
---------------------------------------- The following is ignored
vi /usr/bin/yum
15、 Put the first line #! /usr/bin/python It is amended as follows
#! /usr/bin/python2
16、 There is another area that needs to be revised
vi /usr/libexec/urlgrabber-ext-down
17、 Put the first line #! /usr/bin/python Revised as follows
#! /usr/bin/python2
18、 start-up python2
python2
Insert picture description here
19、 start-up python3
python
cd /usr/local/bin/
python3 -> python3.6
Default 2.7 python3 3.6

reference https://blog.csdn.net/qq_43592674/article/details/116330033

kali


└─# where python2 1 ⨯ 1 
/usr/bin/python2
/bin/python2
┌──(rootamingMM)-[/home/amingmm/Desktop/tplmap-master]
└─# pip -V 1 
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.9)

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