python3版本降级

环境:

MacOS 11.1

说明:

已经安装了python3.9

但是在安装pip 安装python airtest第三方库,报error:No matching distribution found for opencv-contrib-python<=3.4.2.17 (from airtest)

经过排查,发现该库目前不支持python3.8,所以现在将python3.9降级为3.6

目标:mac有自带的python2,在降级python3的同时,不希望系统自带的python2受到影响 

1、移除现有Python

bogon:~ lz1$ brew unlink python3
Unlinking /usr/local/Cellar/python@3.9/3.9.1_6... 25 symlinks removed

2、安装3.6.5

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb

参考文档:详解python 降级到3.6终极解决方案

删除非brew安装的python3方法

Mac卸载Python3的方法(非系统自带Python2)

注意这1步

删除系统环境变量配置文件中python的相关配置:

sudo vi ~/.bash_profile
  • 1

输入系统密码后,光标移动到以下Python配置每行按 i 删除共4行配置,按【ESC】键跳到命令模式,按下冒号按键,然后再按下 wq 回车,即可保存退出vi的编辑状态。

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH


这里可以看到python3.6.5的安装目录
删除掉3.6的文件夹


Mac 安装及卸载 Python3 详细教程

原文地址:https://www.cnblogs.com/kaerxifa/p/14277979.html