0

I have both installed (Python 2.7 and 3.5), and I have Anaconda2\python as my Project Interpreter on PyCharm. However, this doesn't seem to be enough to get ipython Notebook to open up using Python 2.7.

How can I make iPython Notebook to default to Python 2, as opposed to 3, or give me an option to select which one I open Notebook with?

Right now, it is not even an option to select the kernel (?) from within Notebook:

enter image description here

Even after following the instructions here, there is only one kernel option:

enter image description here

Interestingly, I see what I want (separate options for Python 2 and 3) only when I have a proprietary software environment activated, and then I open Notebook:

enter image description here

This is not a workable solution, since this product is a trial version. Plus there ought to be a way of making both kernels available independent of this workaround.

Community
  • 1
  • 1
Antoni Parellada
  • 4,253
  • 6
  • 49
  • 114

1 Answers1

2

Here are the instructions to make a Python 2 kernel available in addition to the Python 3 kernel that's already there. Copied in:

If you’re running Jupyter on Python 3, you can set up a Python 2 kernel like this:

python2 -m pip install ipykernel
python2 -m ipykernel install --user

Or using conda, create a Python 2 environment:

conda create -n ipykernel_py2 python=2 ipykernel
source activate ipykernel_py2    # On Windows, remove the word 'source'
python -m ipykernel install --user

If you’re running Jupyter on Python 2 and want to set up a Python 3 kernel, follow the same steps, replacing 2 with 3.

The last command installs a kernel spec file for the current python installation. Kernel spec files are JSON files, which can be viewed and changed with a normal text editor.

Thomas K
  • 39,200
  • 7
  • 84
  • 86