python - 如何在 MacOS 上绝对卸载 python 2.7

标签 python macos

我已经安装了 python 3.6.5(带有brew),当我在 shell 中执行 python 命令时,总是出现 python 2.7。

我已经执行了这些命令,请参阅 other post但没有任何作用:

Remove the third-party Python 2.7 framework

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

Remove the Python 2.7 applications directory

sudo rm -rf "/Applications/Python 2.7"

Remove the symbolic links in /usr/local/bin that point to this Python version see ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' and then run the following command to remove all the links:

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

最佳答案

macOS 中始终存在一个系统 Python 2.7 (/usr/bin/python),您无法真正删除它。

如果您想运行 Python 3,请使用 python3

参见PEP 0394有关命名法的详细信息。

关于python - 如何在 MacOS 上绝对卸载 python 2.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50490569/

相关文章:

Python:拆分字符串行

python - pyspark:仅基于 rdd 的操作

macos - 在哪里可以找到从 gpusGenerateCrashLog 调用堆栈创建的日志?

macos - "ERROR: broken data stream when reading image file"(OS X 上的 TrueType 字体 libjpeg 和 PIL)

python - "Third order"Kneser-Key 平滑的正确实现(对于 Trigram 模型)

python - 具有动态形状的变量 TensorFlow

python - 哪个 SKLearn 接口(interface)定义了 .fit、.predict 等

macos - 绑定(bind) nsrect 和 nstextfield

macos - NSCollectionView 拖放示例

java - file.getParentFile().mkdirs();在 osx 中创建重复的文件夹