卸载老版本python


以Python3.6为例

  • 删除Python 3.6 framework
    sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.6

  • 删除Python 3.6 应用目录
    sudo rm -rf "/Applications/Python 3.6"

  • 删除/usr/local/bin 目录下指向的Python3.6的连接
    ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.6' | awk '{print $9}' | tr -d @ | xargs rm

  • 删除环境变量
    一般是在~/bash_profile下删除对应3.6的配置即可

更新python


直接去python官网下载安装包即可

更新pip3


pip3 install -U pip

安装virtualenv


pip3 install virtualenv

创建虚拟环境


指定python3版本,创建一个干净的虚拟运行环境
virtualenv --no-site-packages --python=python3 py3env

XXX@lXXXMBP:~/DayDayUp/django/testpro-admin-server/py3env$ ll
total 16
drwxr-xr-x   7 xxx  staff  238  3  5 19:12 ./
drwxr-xr-x   3 xxx  staff  102  3  5 19:12 ../
lrwxr-xr-x   1 xxx  staff   56  3  5 19:12 .Python@ -> /Library/Frameworks/Python.framework/Versions/3.7/Python
drwxr-xr-x  16 xxx  staff  544  3  5 19:12 bin/
drwxr-xr-x   3 xxx  staff  102  3  5 19:12 include/
drwxr-xr-x   3 xxx  staff  102  3  5 19:12 lib/
-rw-r--r--   1 xxx  staff   61  3  5 19:12 pip-selfcheck.json
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐