zoukankan      html  css  js  c++  java
  • Mac 卸载Python3.6

    Mac 自带的 Python 已经能够满足我们的需要了,因此很多同学在安装完 Python 之后,又想要将其删除,或者称之为卸载。
    对于删除 Python,我们首先要知道其具体都安装了什么,实际上,在安装 Python 时,其自动生成:

    1)Python framework,即 Python 框架;
    2)Python 应用目录;
    3)指向 Python 的连接。

    对于 Mac 自带的 Python,其框架目录为:
    System/Library/Frameworks/Python.framework
    
    而我们安装的 Python,其(默认)框架目录为:
    /Library/Frameworks/Python.framework
    

    接下来,我们就分别(在 Mac 终端进行)删除上面所提到的三部分。

    第 1 步,删除框架:

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

    第 2步,删除应用目录:

    sudo rm -rf "/Applications/Python 3.6"
    

    第 3 步,删除指向 Python 的连接:

    cd /usr/local/bin/
    ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.6' | awk '{print $9}' | tr -d @ | xargs rm
    

    至此,我们已经成功删除 Python 的相关文件,其中3.6为 Python 的版本号。

    Mac安装python的一些注意事项

    使用brew install python3 会把python安装到/usr/local/Cellar/python/下。尽量不要使用brew方式安装Python

     brew list python
    /usr/local/Cellar/python/3.7.7/bin/2to3
    /usr/local/Cellar/python/3.7.7/bin/2to3-3.7
    /usr/local/Cellar/python/3.7.7/bin/easy_install-3.7
    /usr/local/Cellar/python/3.7.7/bin/idle3
    /usr/local/Cellar/python/3.7.7/bin/idle3.7
    /usr/local/Cellar/python/3.7.7/bin/pip3
    /usr/local/Cellar/python/3.7.7/bin/pip3.7
    /usr/local/Cellar/python/3.7.7/bin/pydoc3
    /usr/local/Cellar/python/3.7.7/bin/pydoc3.7
    /usr/local/Cellar/python/3.7.7/bin/python3
    /usr/local/Cellar/python/3.7.7/bin/python3-config
    /usr/local/Cellar/python/3.7.7/bin/python3.7
    /usr/local/Cellar/python/3.7.7/bin/python3.7-config
    /usr/local/Cellar/python/3.7.7/bin/python3.7m
    /usr/local/Cellar/python/3.7.7/bin/python3.7m-config
    /usr/local/Cellar/python/3.7.7/bin/pyvenv
    /usr/local/Cellar/python/3.7.7/bin/pyvenv-3.7
    /usr/local/Cellar/python/3.7.7/bin/wheel3
    /usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/ (2730 files)
    /usr/local/Cellar/python/3.7.7/IDLE 3.app/Contents/ (8 files)
    /usr/local/Cellar/python/3.7.7/lib/pkgconfig/ (3 files)
    /usr/local/Cellar/python/3.7.7/libexec/bin/ (7 files)
    /usr/local/Cellar/python/3.7.7/libexec/pip/ (794 files)
    /usr/local/Cellar/python/3.7.7/libexec/setuptools/ (365 files)
    /usr/local/Cellar/python/3.7.7/libexec/wheel/ (60 files)
    /usr/local/Cellar/python/3.7.7/Python Launcher 3.app/Contents/ (16 files)
    /usr/local/Cellar/python/3.7.7/share/man/ (2 files)
    
    

    brew uninstall python3 会把/usr/local/Cellar/下的python删掉
    brew uninstall --ignore-dependencies python@3.8

    安装 autopep8

    chown -R $USER /Users/zhangxm/Library/Python

    MacBookPro:vscode zhangxm$ /usr/local/bin/python3 /Users/zhangxm/.vscode/extensions/ms-python.python-2021.3.680753044/pythonFiles/pyvsc-run-isolated.py pip install -U autopep8 --user
    Collecting autopep8
      Using cached autopep8-1.5.6-py2.py3-none-any.whl (44 kB)
    Collecting pycodestyle>=2.7.0
      Using cached pycodestyle-2.7.0-py2.py3-none-any.whl (41 kB)
    Collecting toml
      Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
    Installing collected packages: toml, pycodestyle, autopep8
      WARNING: The script pycodestyle is installed in '/Users/zhangxm/Library/Python/3.9/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      WARNING: The script autopep8 is installed in '/Users/zhangxm/Library/Python/3.9/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
    Successfully installed autopep8-1.5.6 pycodestyle-2.7.0 toml-0.10.2
    MacBookPro:vscode zhangxm$ 
    

    创建python虚拟环境

    python3 -m venv .venv

  • 相关阅读:
    176. Second Highest Salary
    175. Combine Two Tables
    172. Factorial Trailing Zeroes
    171. Excel Sheet Column Number
    169. Majority Element
    168. Excel Sheet Column Title
    167. Two Sum II
    160. Intersection of Two Linked Lists
    个人博客记录
    <meta>标签
  • 原文地址:https://www.cnblogs.com/xidianzxm/p/12009127.html
Copyright © 2011-2022 走看看