检索默认的Mac Python 2.7而不是Anaconda Python 3.6.5

时间:2018-08-23 16:17:14

标签: python-3.x python-2.7 anaconda python-3.6 default

安装Anaconda之后...

我设法通过以下方式检索从Python.org下载的Python 3.6.6,而不是Anaconda的版本:

open .bash_profile

并注释掉最后一行:

# export PATH="/anaconda3/bin:$PATH"

现在,当我需要运行Python 3.6.6时,只需输入Terminal python3。

我需要对Python 2.7做同样的事情,这是我的默认系统python。当我仅在终端中键入python时,便获得了Anaconda Python 3.6.5版本。

是否有与上述解决方案类似的方法来编辑默认的Python 2.7配置文件?

请注意以下几点:

$ which -a python
/anaconda3/bin/python
/usr/bin/python

$ which python
/anaconda3/bin/python

$ python # Here I need python 2.7
Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

$ which -a python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
/anaconda3/bin/python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
/usr/local/bin/python3

如何删除未使用的python3目录/ PATH,并仅保留其中一个?

$ which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3

$ python3
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 26 2018, 19:50:54) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

0 个答案:

没有答案