Using both Python 2.x and Python 3.x in IPython Notebook

后端 未结 11 2158
生来不讨喜
生来不讨喜 2020-11-22 02:27

I use IPython notebooks and would like to be able to select to create a 2.x or 3.x python notebook in IPython.

I initially had Anaconda. With Anaconda a global envi

11条回答
  •  孤街浪徒
    2020-11-22 03:23

    A solution is available that allows me to keep my MacPorts installation by configuring the Ipython kernelspec.

    Requirements:

    • MacPorts is installed in the usual /opt directory
    • python 2.7 is installed through macports
    • python 3.4 is installed through macports
    • Ipython is installed for python 2.7
    • Ipython is installed for python 3.4

    For python 2.x:

    $ cd /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin
    $ sudo ./ipython kernelspec install-self
    

    For python 3.x:

    $ cd /opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin
    $ sudo ./ipython kernelspec install-self
    

    Now you can open an Ipython notebook and then choose a python 2.x or a python 3.x notebook.

提交回复
热议问题