如何在mac上更改ipython的python解释器?

时间:2017-12-12 07:09:29

标签: python macos python-3.x python-2.7 macos-sierra

我的mac上的以下文件夹中有python库

  • /usr/local/lib/python2.7/site-packages/
  • /usr/local/lib/python3.6/site-packages/

和,相应的二进制文件为以下文件

  • /usr/local/bin/python2.7
  • /usr/local/bin/python3.6

但是,ipython二进制文件在/usr/local/Cellar/ipython/6.2.1/bin/ipython中,而ipython文件/usr/local/bin/ipython中包含以下行 -

PYTHONPATH="/usr/local/Cellar/ipython/6.2.1/libexec/lib/python3.6/site-packages:/usr/local/Cellar/ipython/6.2.1/libexec/vendor/lib/python3.6/site-packages" exec "/usr/local/Cellar/ipython/6.2.1/libexec/bin/ipython" "$@"

因此,在终端中执行ipython时,系统将默认解释器视为python3.6。如何修改这些文件以将python解释器从3.6更改为2.7?

以下是我的mac中所有ipython *文件的屏幕截图。

enter image description here

1 个答案:

答案 0 :(得分:1)

从版本6开始,IPython不再与Python 2.x兼容。

你可以继续使用IPython 6和Python 3,或者降级到IPython 5并使用Python 2。

http://ipython.readthedocs.io/en/stable/whatsnew/version6.html#ipython-6-0 https://github.com/Homebrew/brew/issues/2849