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

deltap

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 environment variable had to be changed to select what version of python you want and then IPython could be started. This is not what I was looking for so I uninstalled Anaconda and now have set up my own installation using MacPorts and PiP. It seems that I still have to use

port select --set python <python version> 

to toggle between python 2.x and 3.x. which is no better than the anaconda solution.

Is there a way to select what version of python you want to use after you start an IPython notebook, preferably with my current MacPorts build?

deltap

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.

Choose your python!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Install several new versions of Python3.x on an IPython notebook

From Dev

Anaconda: Python 3 and 2 in IPython/Jupyter Notebook

From Dev

What is the correct syntax for launching ipython qtconsole/notebook for python version=x

From Dev

What is the correct syntax for launching ipython qtconsole/notebook for python version=x

From Dev

Python 3.x : Jupyter Notebook and Pandas

From Dev

Valid syntax in both Python 2.x and 3.x for raising exception?

From Dev

IPython Notebook in a virtualenv, using Python 3.3

From Dev

install ipython for current python version 2.x

From Dev

Have IPython run using Python 3 and not Python 2

From Dev

I want to use both python 2.7 and 3.x in jupyter

From Dev

Is it possible to create GTK+2.x applications using Python 3?

From Dev

Python: Eval with undefined variables (2*x+x = 3*x)

From Java

Why is 2 * x * x faster than 2 * ( x * x ) in Python 3.x, for integers?

From Dev

Why is 2 * x * x faster than 2 * ( x * x ) in Python 3.x, for integers?

From Dev

Script incompatibility for Python 2.x and Python 3.x

From Dev

Geocoding Strategies - Python 2.x to Python 3.x

From Dev

How to install pyzmq for iPython Notebook in a Python 3 virtual environment?

From Dev

Using the For statement in python 3x

From Dev

Printing 2 Python Pandas DataFrame in HTML Tables in iPython Notebook

From Dev

iPython runs on Python 3 instead of Python 2

From Dev

Deal with buffer in Python 2.x and 3.x

From Dev

Regex unicode in python 2.x vs 3.x

From Dev

Deal with buffer in Python 2.x and 3.x

From Dev

Accessing Python2.x and 3.x in windows

From Dev

binary using both Python C API version 2 and 3

From Dev

print in python using python3 without python2 and python1 or both at the same time?

From Dev

Ipython notebook - Create a new notebook (Python conda or default Python)

From Dev

iPython 3 uses Python 2 instead of Python 3

From Dev

iPython 3 uses Python 2 instead of Python 3

Related Related

  1. 1

    Install several new versions of Python3.x on an IPython notebook

  2. 2

    Anaconda: Python 3 and 2 in IPython/Jupyter Notebook

  3. 3

    What is the correct syntax for launching ipython qtconsole/notebook for python version=x

  4. 4

    What is the correct syntax for launching ipython qtconsole/notebook for python version=x

  5. 5

    Python 3.x : Jupyter Notebook and Pandas

  6. 6

    Valid syntax in both Python 2.x and 3.x for raising exception?

  7. 7

    IPython Notebook in a virtualenv, using Python 3.3

  8. 8

    install ipython for current python version 2.x

  9. 9

    Have IPython run using Python 3 and not Python 2

  10. 10

    I want to use both python 2.7 and 3.x in jupyter

  11. 11

    Is it possible to create GTK+2.x applications using Python 3?

  12. 12

    Python: Eval with undefined variables (2*x+x = 3*x)

  13. 13

    Why is 2 * x * x faster than 2 * ( x * x ) in Python 3.x, for integers?

  14. 14

    Why is 2 * x * x faster than 2 * ( x * x ) in Python 3.x, for integers?

  15. 15

    Script incompatibility for Python 2.x and Python 3.x

  16. 16

    Geocoding Strategies - Python 2.x to Python 3.x

  17. 17

    How to install pyzmq for iPython Notebook in a Python 3 virtual environment?

  18. 18

    Using the For statement in python 3x

  19. 19

    Printing 2 Python Pandas DataFrame in HTML Tables in iPython Notebook

  20. 20

    iPython runs on Python 3 instead of Python 2

  21. 21

    Deal with buffer in Python 2.x and 3.x

  22. 22

    Regex unicode in python 2.x vs 3.x

  23. 23

    Deal with buffer in Python 2.x and 3.x

  24. 24

    Accessing Python2.x and 3.x in windows

  25. 25

    binary using both Python C API version 2 and 3

  26. 26

    print in python using python3 without python2 and python1 or both at the same time?

  27. 27

    Ipython notebook - Create a new notebook (Python conda or default Python)

  28. 28

    iPython 3 uses Python 2 instead of Python 3

  29. 29

    iPython 3 uses Python 2 instead of Python 3

HotTag

Archive