Setting up IPython Notebook on Windows

Update (Feb 2016): These instructions are now outdated.
The recommended way to install Jupyter (new name for IPython Notebook) is now using Anaconda.

IPython Notebook is a great tool for prototyping algorithms and analysing data interactively, in particular in combination with powerful numerical libraries such as NumPy, SciPy, matplotlib and OpenCV. But one step after the other.

The IPython install page mentions Python distributions such as Anaconda or Enthought Canopy that come with many packages pre-installed, but I prefer to install all bits from scratch, so I know what’s installed.

So let’s get started on how to install IPython Notebook on Windows 7. Obviously we need admin rights for all of this.

  1. Install Python
    A late 2-series Python, such as 2.7.5, provides the best compatibility with most packages, although support for Python 3 is continuously improving. I also stick to the Win32 (x86) version of Python as a few packages are not available in x64 versions, although the major packages do support this. My favourite Python distribution for Windows is ActivePython. Note that its default install path is C:\Python27\, which should be changed, e.g. to C:\Program Files (x86)\ActivePython 2.7.5\.
  2. Install IPython
    The easiest way is to run easy_install ipython[all] as an administrator (start button, type cmd, shift+right click on “cmd.exe” and select “Run as administrator”). This installs the latest stable version of IPython including the main required and optional dependencies.
  3. Install libraries
    Download and run the official installers for the latest stable versions of NumPy (numerical routines), SciPy (scientific computing) and matplotlib (graphing library). Make sure you pick the version that fits your Python distribution (e.g. win32 python2.7). Note that matplotlib requires additional dependencies that can be installed using easy_install python-dateutil pyparsing .
  4. Install OpenCV bindings (optional)
    If one works with image processing or computer vision, the Python bindings of OpenCV can be really useful. The python bindings are included in the main OpenCV installer under the path ./build/python/, but as of OpenCV 2.4.8 only Python 2.7 is included as precompiled Python binary (but for both 32 and 64-bit versions). The file “cv2.pyd” needs to be manually copied to the “site-packages” folder of the Python distribution, e.g. at C:\Program Files (x86)\ActivePython 2.7.5\Lib\site-packages\.
  5. Start IPython Notebook
    Run ipython notebook in a command line. If you’re new to IPython Notebook, get started by looking at the example collection and reading the documentation.
  6. Install MathJax locally (optional)
    Typesetting LaTeX within a notebook uses MathJax, which can be installed locally by running the following in Python:

    from IPython.external.mathjax import install_mathjax
    install_mathjax()

As of March 2014, the latest versions of libraries were: IPython 1.2.1, NumPy 1.8.0, SciPy 0.13.3, matplotlib 1.3.1, OpenCV 2.4.8.

37 Responses to “Setting up IPython Notebook on Windows”

  1. Max

    The problem is, you haven’t explained how to use easy_install.

    Reply
  2. Sean

    Hi, this was really helpful, but I can only run ipython and ipython notebook if I run the commands from an administrator terminal.

    Reply
  3. Jack

    Just to share some experience: for one that does not work…please use ActivePython as mentioned in the article, rather than the normal Python downloaded from Python.org.

    Reply
  4. Rui Luo

    Tried several versions. The 2.7.8.10 (x86) active python has easy_install built in. After installing the python, you can directly run easy_install under cmd.exe

    Reply
  5. Tanya

    steps 1-3 worked fine. However trying to run ipython notebook is step 5, I get an error that ipython is not recognized as an internal or external command.

    Reply
    • Christian Richardt

      Looks like ipython is not in the PATH. I think ActivePython should add the correct directory to the path (e.g. C:\Program Files (x86)\ActivePython 2.7.5\Scripts\) during installation.

      However, maybe your command line doesn’t use the latest value of the PATH, for example if you opened it before installing ActivePython. Try opening a new command line window (as a normal user) and see if ipython is found now.

      If not, you may have to log off and on again, and try again. If this still doesn’t work, then the directory I mentioned above is probably missing from the PATH, so you need to add it yourself.

      Reply
    • Egor

      I’ve install ipython through easy_install and I have not found iputhon folder in PATH
      I follow Christian’s comment and problem was solved by adding to PATH
      C:\Python27\Scripts

      Reply
  6. AlexS

    Thanks a lot for such a good step by step explanation! Everything started working after the very first try.

    Reply
  7. Colin J. Williams

    Richardt,

    I have downloaded Anaconda and run the following script:

    C:\Users\cjw_2>ipython notebook
    C:\Python27\lib\site-packages\numpy\core\__init__.py:6: Warning: Numpy 64bit experimental build with
    Mingw-w64 and OpenBlas.
    from . import multiarray
    2015-01-31 13:42:14.296 [NotebookApp] Using existing profile dir: u’C:\\Users\\cjw_2\\.ipython\\prof
    ile_default’
    2015-01-31 13:42:14.312 [NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest
    /MathJax.js
    2015-01-31 13:42:14.344 [NotebookApp] Serving notebooks from local directory: C:\Users\cjw_2
    2015-01-31 13:42:14.344 [NotebookApp] 0 active kernels
    2015-01-31 13:42:14.359 [NotebookApp] The IPython Notebook is running at: http://localhost:8888/
    2015-01-31 13:42:14.359 [NotebookApp] Use Control-C to stop this server and shut down all kernels (t
    wice to skip confirmation).

    Do you have any advice?

    Colin W.

    Reply
  8. Marks

    When I enter “ipython notebook”, I was told “UnicodeDecodeError:’utf8′ codec can’t decode byte 0xbb in position invtart byte”.
    Please help me. I have been struggling in installing ipython for a whole way only to find I am not that smart.

    Reply
  9. Xinh

    easy_install ipython[all] does not work for me.
    I install python x86 in C:\Program Files (x86)\ActivePython 2.7.8
    Please help

    Reply
    • Christian Richardt

      Could you please be more specific? What error do you get? Could it be related to one of the other easy_install issues already discussed above?

      Reply
  10. Rafa

    Hi,
    I am getting this below. Do I need to install ipywidgets?:

    PS C:\Program Files (x86)\Python27> ipython notebook
    [I 16:38:50.576 NotebookApp] Copying C:\Users\rafa\.ipython\nbextensions -> C:\Users\rafa\AppData\Roaming\jupyter\nbexte
    nsions
    [W 16:41:11.332 NotebookApp] ipywidgets package not installed. Widgets are unavailable.
    [I 16:41:11.358 NotebookApp] Serving notebooks from local directory: C:\Program Files (x86)\Python27
    [I 16:41:11.359 NotebookApp] 0 active kernels
    [I 16:41:11.361 NotebookApp] The IPython Notebook is running at: http://localhost:8888/
    [I 16:41:11.361 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

    Reply
    • swathi

      Microsoft Windows [Version 6.1.7600]
      Copyright (c) 2009 Microsoft Corporation. All rights reserved.

      C:\Users\CBIT>cd\

      C:\>cd Python27

      C:\Python27>ipython notebook
      [I 15:29:19.388 NotebookApp] Serving notebooks from local directory: C:\Python27

      [I 15:29:19.388 NotebookApp] 0 active kernels
      [I 15:29:19.388 NotebookApp] The IPython Notebook is running at: http://localhos
      t:8888/
      [I 15:29:19.388 NotebookApp] Use Control-C to stop this server and shut down all
      kernels (twice to skip confirmation).
      [W 15:29:19.657 NotebookApp] 404 GET /static/components/bootstrap/fonts/glyphico
      ns-halflings-regular.eot? (::1) 10.00ms referer=http://localhost:8888/tree
      i am getting this, and blank on the explorer, what’s the problem

      Reply
  11. TomQ

    If I try running easy_install ipython[all] I get:

    Running gnureadline-6.3.3\setup.py -q bdist_egg –dist-dir c:\users\tomq\appdata\local\temp\easy_install-cyoflt\gnureadline-6.3.3\egg-dist-tmp-npzt0y
    error: Setup script exited with Error: this module is not meant to work on Windows (try pyreadline instead)

    I have activestate python 32 bit. I have tried manually installing pyreadline, but makes no difference.

    Any ideas?

    Reply
      • TomQ

        By a process of just manually installing individual packages as it gave me errors about this that and the other not being found, I have finally got a running system.

        pip install python does essentially the same thing, fails on gnureadline.

        Reply
  12. Mike S

    I installed IPython using the directions above on WinXPSP, I already have Python 3.4.4 installed. When I run ipython notebook from a command line I see a new page in my browser but it doesn’t have the IPython control panel, it has 3 Tabs: Files, Running, Clusters, and when I click “New” to start a notebook “Notebooks” is disabled. Also on the Running tab no terminals or notebooks are running. I clicked on “Untitled.ipynb” to see if that would start a notebook, and it does, a new Tab opened in the browser, with what looks like the correct control panel, and a place to type code : In [ ]:, but I see “Kernel Error” in the browser and a bunch of errors in the CLI and then it terminates IPython. I’ll paste the beginning and end of the error listing from the command line. Any help will be much appreciated.

    C:\python34>ipython notebook
    [I 00:38:56.254 NotebookApp] Serving notebooks from local directory: C:\python34

    [I 00:38:56.254 NotebookApp] 0 active kernels
    [I 00:38:56.254 NotebookApp] The Jupyter Notebook is running at: http://localhos
    t:8888/
    [I 00:38:56.254 NotebookApp] Use Control-C to stop this server and shut down all
    kernels (twice to skip confirmation).
    Assertion failed: Socket operation on non-socket (bundled\zeromq\src\select.cpp:
    185)
    Assertion failed: Socket operation on non-socket (bundled\zeromq\src\select.cpp:
    185)
    [E 00:39:18.737 NotebookApp] Unhandled error in API request
    ….
    [E 00:39:18.784 NotebookApp] 500 POST /api/sessions (127.0.0.1) 3468.57ms refere
    r=http://localhost:8888/notebooks/Untitled.ipynb

    C:\python34>Assertion failed: Socket operation on non-socket (bundled\zeromq\src
    \select.cpp:185)
    Assertion failed: Socket operation on non-socket (bundled\zeromq\src\signaler.cp
    p:181)

    Reply
      • MIke S

        Thank you for your quick reply and for looking into this. I turned off the antivirus and firewall, uninstalled ipython, upgraded pip to the lastest version, installed the latest version of ipython[all], still seeing problems. I ran iptest and the lib section failed, I hope you don’ t mind me posting the results here:

        Test group: lib
        ………………………S……..F……….S………………….
        ======================================================================
        FAIL: testIPythonLexer (IPython.lib.tests.test_lexers.TestLexers)
        ———————————————————————-
        Traceback (most recent call last):
        File “c:\python34\lib\site-packages\IPython\lib\tests\test_lexers.py”, line 26, in testIPythonLexer
        self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
        nose.proxy.AssertionError: Lists differ: [(Tok[65 chars]), (Token.Name.Variable,
        ‘$HOME’), (Token.Text, ‘\n’)] != [(Tok[65 chars]), (Token.Text, ‘$’), (Token.Text, ‘HOME’), (Token.Text, ‘\n’)]

        First differing element 3:
        (Token.Name.Variable, ‘$HOME’)
        (Token.Text, ‘$’)

        Second list contains 1 additional elements.
        First extra element 5:
        (Token.Text, ‘\n’)

        [(Token.Operator, ‘!’),
        (Token.Name.Builtin, ‘echo’),
        (Token.Text, ‘ ‘),
        – (Token.Name.Variable, ‘$HOME’),
        + (Token.Text, ‘$’),
        + (Token.Text, ‘HOME’),
        (Token.Text, ‘\n’)]
        “””Fail immediately, with the given message.”””
        >> raise self.failureException(“Lists differ: [(Tok[65 chars]), (Token.Name.Variable, ‘$HOME’), (Token.Text, ‘\\n’)] != [(Tok[65 chars]), (Token.Text, ‘$’), (Token.Text, ‘HOME’), (Token.Text, ‘\\n’)]\n\nFirst differing element 3:\n(Token.Name.Variable, ‘$HOME’)\n(Token.Text, ‘$’)\n\nSecond list contains 1 additional elements.\nFirst extra element 5:\n(Token.Text, ‘\\n’)\n\n [(Token.Operator, ‘!’),\n (Token.Name.Builtin, ‘echo’),\n (Token.Text, ‘ ‘),\n- (Token.Name.Variable, ‘$HOME’),\n+ (Token.Text, ‘$’),\n+ (Token.Text, ‘HOME’),\n (Token.Text, ‘\\n’)]”)
        ———————————————————————-
        Ran 70 tests in 6.234s
        FAILED (SKIP=2, failures=1)

        Reply
        • Christian Richardt

          I have no idea about this and again couldn’t find any solution about this.

          If I had to guess, I would blame the unusual combination of Windows XP and the latest Jupyther/Python 3.4. Although Windows XP is officially supported by Python 3.4, the Jupyter developer perhaps may not have test Windows XP anymore.

          One thing you could try is to install Anaconda (https://www.continuum.io/downloads#_windows), which bundles everything you should need.

          Reply
  13. peng

    Hi Christian,

    Thank you very much for writing such a great post! I’m in China now and wasn’t able to download Anaconda from its website. Your post helped me take a detour and solve my problem. Thank you!

    Reply
  14. Ben

    Christian,

    You deserve a round of applause for following up on so many problems with such great research. This page catapulted me forward in my quest to install IPython on Windows. Thanks for your time and effort here!

    Ben

    Reply

Leave a Reply