kali安装python27&&替换版本

kali命令↓

$ sudo apt update


$ sudo apt install build-essential libssl-dev libbz2-dev libreadline-dev libsqlite3-dev zlib1g-dev


$ wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz


$ tar -xvf Python-2.7.18.tgz


$ cd Python-2.7.18


$ ./configure --enable-optimizations


$ make && sudo make install


$ sudo update-alternatives --config python   #选择版本


$  wget https://bootstrap.pypa.io/pip/2.7/get-pip.py 



$ sudo ln -s /usr/local/bin/pip2.7 /usr/bin/pip



$ pip uninstall xlrd      #卸载高版本


$ python2.7 -m pip install xlrd==1.2.0 
#使用 pip 为 Python 2.7 安装 xlrd 版本 1.2.0。为了确保安装到 Python 2.7 的 pip。
你可以使用 python2.7 -m pip 命令。



$ python2.7 -c "import xlrd; print(xlrd.__version__)"


python替换版本↓

#将 Python 2 和 Python 3 的路径添加到 update-alternatives 中。运行以下命令:

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2



#使用以下命令来选择默认的 Python 版本:
$ sudo update-alternatives --config python

There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                   Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python2       1         auto mode
  1            /usr/bin/python2       1         manual mode
  2            /usr/bin/python3       2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 




#检查当前 Python 版本
$ python --version




方法2↓

#步骤 1:删除当前的 python 符号链接
$ sudo rm /usr/bin/python



#步骤 2:创建一个新的符号链接,指向 Python 2
$ sudo ln -s /usr/bin/python2 /usr/bin/python



#步骤 3:验证更改
$ python --version



#安装 pip 对应的 Python 版本
$ sudo apt install python-pip

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值