.. _installJupyter:

.. WARNING: DO NOT EDIT THIS FILE:
   AUTOMATICALLY GENERATED.
   PLEASE EDIT THE .py FILE DIRECTLY.


Using ``music21`` with the Jupyter (iPython) Notebook
=====================================================

Setting up the Jupyter environment
----------------------------------

To get ``music21`` to work it's best to have a good pip installation
first. Then you should be able to simply install jupyter (and IPython if
you don't have it):

``$ sudo pip install jupyter $ sudo pip install ipython``

Using the web-based Jupyter Notebook
------------------------------------

Start jupyter in a directory you want to save files by typing.

```$ jupyter notebook```

Now in the webbrowser you can type commands such as the ones below:

.. code:: ipython3

    from music21 import *

.. code:: ipython3

    c = chord.Chord("C4 E4 G4")
    c.isConsonant()




.. parsed-literal::
   :class: ipython-result

    True



And that is basically it! We use ``sphinx`` for interwiki links, which,
sadly, won't show up on the notebook, but should render properly.

But I did make a sphinx-markdown Notebook extension. When it's ready,
I'll put it up. Make a directory "sphinx-markdown" in a "usability"
directory in "nbextensions" (mine is at
"~/Library/Jupyter/nbextensions"). And put this file there as "main.js":
[https://gist.github.com/mscuthbert/6411762f98f3536712e0]

Check to see if it exists:

.. code:: ipython3

    import notebook
    notebook.nbextensions.check_nbextension('usability/sphinx-markdown', user=True)




.. parsed-literal::
   :class: ipython-result

    True



Load it with:

.. code:: ipython3

    E = notebook.nbextensions.EnableNBExtensionApp()
    E.toggle_nbextension('usability/sphinx-markdown/main')


.. parsed-literal::
   :class: ipython-result

    Enabling notebook extension usability/sphinx-markdown/main...
          - Validating: [32mOK[0m




.. parsed-literal::
   :class: ipython-result

    False



Save, and reload. Then test it with a markdown cell like:

For more information, see, :ref:`installing IPython/Jupyter for Music21 <installJupyter>`.

And you should get this output:

For more information, see,
:ref:`installing IPython/Jupyter for Music21 <installJupyter>`. :-)

It works!