Skip to main content
 首页 » 编程设计

python之当我在 mac 上安装了 python 3.5 时,终端运行 python 2.7。

2025年05月04日9zhenyulu

我在我的 mac 上安装、卸载和重新安装 pythons, 我认为事情有点搞砸了。

起初默认情况下,终端在我输入时运行 Python 3.5

$python 

,但在做了一些事情之后,它安装了 2.7,现在终端运行 python 2.7 而不是 3.5

我安装了 python 3.5 形式 http://python.org/ .

当我打开 bash_profile 时

$vim ~/.bash_profile 

这是显示的内容

# virtualenv 
export WORKON_HOME=~/.virtualenvs 
source /usr/local/bin/virtualenvwrapper.sh 
 
 
# Setting PATH for Python 3.5 
# The orginal version is saved in .bash_profile.pysave 
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}" 
export PATH 

现在当我输入时:

$ python 

这显示:

Python 2.7.11 (default, Jun 23 2016, 17:25:20)  
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>>  

如何将所有 python 东西(删除旧版本等)重置为我第一次购买 Mac(python3.5) 时的出厂版本?

请您参考如下方法:

这对我有用:

Python 3.x

python3 

Python 2.x

python 

in terminal