How To Get IPython Notebook To Run Python 3?

PythonPython 3.xIpythonIpython Notebook

Python Problem Overview


I am new to Python to bear with me.

  1. I installed Anaconda, works great.
  2. I setup a Python 3 environment following the Anaconda cmd line instructions, works great.
  3. I setup Anaconda's Python 3 environment as Pycharm's interpreter, works great.
  4. I launched the Anaconda "launcher.app" and launched IPython Notebook. However, iPython Notebook is running Python 2 not 3.

Over three hours of Googling later, I cannot figure out how to set IPython Notebook to run Python 3 instead of 2.

Python Solutions


Solution 1 - Python

To set IPython Notebook to run Python 3 instead of 2 on my MAC 10.9, I did the following steps

$ sudo pip3 install ipython[all]

Then

$ ipython3 notebook

Solution 2 - Python

For linux 16.04 Ubuntu you can use

sudo apt-get install ipython3

and then use

ipython3 notebook

to open the notebook in the browser. If you have any notebooks saved with python 2 then it will automatically convert them to Python 3 once you open the notebook.

Solution 3 - Python

To use jupyter with python 3 instead of python 2 on my Windows 10 with Anaconda, I did the following steps on anaconda prompt:

pip3 install ipython[all]

Then,

ipython3 notebook

Solution 4 - Python

Is there a package from your distro? If you're using ubuntu you must to install the ipython3-notebook package. If not, maybe you must to install ipython with python3.

If you've run (because it's python2 by default)

python setup.py

you must to run instead

python3 setup.py install

to install a package with python3 instead python2. This will be a new instalation of ipython3.

Solution 5 - Python

In Anaconda "launcher.app" there is “Environment:” pull down menu. The default environment is called "root". In order to launch application using another environment, just select the desired environment from the list, to make it active.

Solution 6 - Python

If you are running anaconda, then the preferred way to install notebook/jupyter is using conda:

conda install jupyter

Solution 7 - Python

If you have both version available on jupyter notebook, you can change the kernel from menu.

Solution 8 - Python

Switch the role of 2 and 3 in this answer as appropriate.

Say you already have jupyter setup with a python 2 kernel and an anaconda environment with python 3. Activate the python 3 enviroment and then run

conda install ipykernel

After that you can select both a 2 and 3 kernel when creating a new notebook, or in a running notebook from the kernels menu.

Solution 9 - Python

Another solution would be to create a virtualenv with python3:

From this environment, install tensorflow (the version you prefer) there:

pip install tensorflow

Run your jupyter from there !

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAntonView Question on Stackoverflow
Solution 1 - PythonNoha ElprinceView Answer on Stackoverflow
Solution 2 - PythonPanosView Answer on Stackoverflow
Solution 3 - PythonMoitreyee DasguptaView Answer on Stackoverflow
Solution 4 - PythonOrlandoView Answer on Stackoverflow
Solution 5 - PythonAndrzej NeugebauerView Answer on Stackoverflow
Solution 6 - PythonPaulView Answer on Stackoverflow
Solution 7 - PythonArun Kumar KhattriView Answer on Stackoverflow
Solution 8 - PythonMathKidView Answer on Stackoverflow
Solution 9 - PythonMax AlonzoView Answer on Stackoverflow