iPython notebook not working in Pycharm

10,500

I found that it is because Pycharm doesn't recognize the new api of IPython 4.2.0 and I just need to uninstall the latest version IPython and install IPython 3.2.3.

Run

$ pip uninstall IPython
$ pip install 'ipython<4'

in terminal and use sudo if permission denied.

Share:
10,500
jinglei
Author by

jinglei

Self taught programmer.

Updated on June 15, 2022

Comments

  • jinglei
    jinglei almost 2 years

    I did exactly as the official guide told.

    For me I didn't have this window pop up when I click the Run buttonenter image description here

    However, when I click the Run button it was just not working and showed a * in the bracket. enter image description here

    In terminal:

    ipython notebook
    [I 21:25:20.940 NotebookApp] Serving notebooks from local directory: /Users/yangyy/GitHub/Signal&System
    [I 21:25:20.941 NotebookApp] 0 active kernels
    [I 21:25:20.941 NotebookApp] The IPython Notebook is running at: http://localhost:8888/
    [I 21:25:20.941 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [W 21:25:24.439 NotebookApp] 404 GET /api/kernels/e905abbe-caad-458e-a50b-a48b7dbcc6ab/channels?session_id=16F0F228133A41AC84E1A2A71F1064F2 (::1): Kernel does not exist: e905abbe-caad-458e-a50b-a48b7dbcc6ab
    [W 21:25:24.446 NotebookApp] 404 GET /api/kernels/e905abbe-caad-458e-a50b-a48b7dbcc6ab/channels?session_id=16F0F228133A41AC84E1A2A71F1064F2 (::1) 14.19ms referer=None
    [E 21:25:30.370 NotebookApp] Notebook JSON is not valid v3: Additional properties are not allowed (u'cells' was unexpected)
    
        Failed validating u'additionalProperties' in schema:
            {u'$schema': u'http://json-schema.org/draft-04/schema#',
             u'additionalProperties': False,
             u'definitions': {u'code_cell': {u'additionalProperties': False,
                                             u'description': u'Notebook code cell.',
                                             u'properties': {u'cell_type': {u'description': u'String identifying the type of cell.',
                                                                            u'enum': [u'code']},
                                                             u'collapsed': {u'description': u'Whether the cell is collapsed/expanded.',
                                                                            u'type': u'boolean'},
                                                             u'input': {u'$ref': u'#/definitions/misc/source'},
                                                             u'language': {u'description': u"The cell's language (always Python)",
                                                                           u'type': u'string'},
                                                             u'metadata': {u'additionalProperties': True,
                                                                           u'description': u'Cell-level metadata.',
                                                                           u'type': u'object'},
                                                             u'outputs': {u'description': u'Execution, display, or stream outputs.',
                                                                          u'items': {u'$ref': u'#/definitions/output'},
                                                                          u'type': u'array'},
                                                             u'prompt_number': {u'description': u"The code cell's prompt number. Will be null if the cell has not been run.",
                                                                                u'minimum': 0,
                                                                                u'type': [u'integer',
                                                                                          u'null']}},
                                             u'required': [u'cell_type',
                                                           u'input',
                                                           u'outputs',
                                                           u'language'],
                                             u'type': u'object'},
                              u'display_data': {u'additionalProperties': False,
                                                u'description': u'Data displayed as a result of code cell execution.',
                                                u'patternProperties': {u'[a-zA-Z0-9]+/[a-zA-Z0-9\\-\\+\\.]+$': {u'$ref': u'#/definitions/misc/multiline_string',
                                                                                                                u'description': u'mimetype output (e.g. text/plain), represented as either an array of strings or a string.'}},
                                                u'properties': {u'html': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                                u'javascript': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                                u'jpeg': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                                u'json': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                                u'latex': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                                u'metadata': {u'$ref': u'#/definitions/misc/output_metadata'},
                                                                u'output_type': {u'description': u'Type of cell output.',
                                                                                 u'enum': [u'display_data']},
                                                                u'pdf': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                                u'png': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                                u'svg': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                                u'text': {u'$ref': u'#/definitions/misc/multiline_string'}},
                                                u'required': [u'output_type'],
                                                u'type': u'object'},
                              u'heading_cell': {u'additionalProperties': False,
                                                u'description': u'Notebook heading cell.',
                                                u'properties': {u'cell_type': {u'description': u'String identifying the type of cell.',
                                                                               u'enum': [u'heading']},
                                                                u'level': {u'description': u'Level of heading cells.',
                                                                           u'minimum': 1,
                                                                           u'type': u'integer'},
                                                                u'metadata': {u'additionalProperties': True,
                                                                              u'description': u'Cell-level metadata.',
                                                                              u'type': u'object'},
                                                                u'source': {u'$ref': u'#/definitions/misc/source'}},
                                                u'required': [u'cell_type',
                                                              u'source',
                                                              u'level'],
                                                u'type': u'object'},
                              u'markdown_cell': {u'additionalProperties': False,
                                                 u'description': u'Notebook markdown cell.',
                                                 u'properties': {u'cell_type': {u'description': u'String identifying the type of cell.',
                                                                                u'enum': [u'markdown',
                                                                                          u'html']},
                                                                 u'metadata': {u'additionalProperties': True,
                                                                               u'description': u'Cell-level metadata.',
                                                                               u'properties': {u'name': {u'$ref': u'#/definitions/misc/metadata_name'},
                                                                                               u'tags': {u'$ref': u'#/definitions/misc/metadata_tags'}},
                                                                               u'type': u'object'},
                                                                 u'source': {u'$ref': u'#/definitions/misc/source'}},
                                                 u'required': [u'cell_type',
                                                               u'source'],
                                                 u'type': u'object'},
                              u'misc': {u'metadata_name': {u'description': u"The cell's name. If present, must be a non-empty string.",
                                                           u'pattern': u'^.+$',
                                                           u'type': u'string'},
                                        u'metadata_tags': {u'description': u"The cell's tags. Tags must be unique, and must not contain commas.",
                                                           u'items': {u'pattern': u'^[^,]+$',
                                                                      u'type': u'string'},
                                                           u'type': u'array',
                                                           u'uniqueItems': True},
                                        u'mimetype': {u'patternProperties': {u'^[a-zA-Z0-9\\-\\+]+/[a-zA-Z0-9\\-\\+]+': {u'$ref': u'#/definitions/misc/multiline_string',
                                                                                                                         u'description': u"The cell's mimetype output (e.g. text/plain), represented as either an array of strings or a string."}}},
                                        u'multiline_string': {u'oneOf': [{u'type': u'string'},
                                                                         {u'items': {u'type': u'string'},
                                                                          u'type': u'array'}]},
                                        u'output_metadata': {u'additionalProperties': True,
                                                             u'description': u'Cell output metadata.',
                                                             u'type': u'object'},
                                        u'prompt_number': {u'description': u"The code cell's prompt number. Will be null if the cell has not been run.",
                                                           u'minimum': 0,
                                                           u'type': [u'integer',
                                                                     u'null']},
                                        u'source': {u'$ref': u'#/definitions/misc/multiline_string',
                                                    u'description': u'Contents of the cell, represented as an array of lines.'}},
                              u'output': {u'oneOf': [{u'$ref': u'#/definitions/pyout'},
                                                     {u'$ref': u'#/definitions/display_data'},
                                                     {u'$ref': u'#/definitions/stream'},
                                                     {u'$ref': u'#/definitions/pyerr'}],
                                          u'type': u'object'},
                              u'pyerr': {u'additionalProperties': False,
                                         u'description': u'Output of an error that occurred during code cell execution.',
                                         u'properties': {u'ename': {u'description': u'The name of the error.',
                                                                    u'type': u'string'},
                                                         u'evalue': {u'description': u'The value, or message, of the error.',
                                                                     u'type': u'string'},
                                                         u'output_type': {u'description': u'Type of cell output.',
                                                                          u'enum': [u'pyerr']},
                                                         u'traceback': {u'description': u"The error's traceback, represented as an array of strings.",
                                                                        u'items': {u'type': u'string'},
                                                                        u'type': u'array'}},
                                         u'required': [u'output_type',
                                                       u'ename',
                                                       u'evalue',
                                                       u'traceback'],
                                         u'type': u'object'},
                              u'pyout': {u'additionalProperties': False,
                                         u'description': u'Result of executing a code cell.',
                                         u'patternProperties': {u'^[a-zA-Z0-9]+/[a-zA-Z0-9\\-\\+\\.]+$': {u'$ref': u'#/definitions/misc/multiline_string',
                                                                                                          u'description': u'mimetype output (e.g. text/plain), represented as either an array of strings or a string.'}},
                                         u'properties': {u'html': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                         u'javascript': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                         u'jpeg': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                         u'json': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                         u'latex': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                         u'metadata': {u'$ref': u'#/definitions/misc/output_metadata'},
                                                         u'output_type': {u'description': u'Type of cell output.',
                                                                          u'enum': [u'pyout']},
                                                         u'pdf': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                         u'png': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                         u'prompt_number': {u'description': u"A result's prompt number.",
                                                                            u'minimum': 0,
                                                                            u'type': [u'integer']},
                                                         u'svg': {u'$ref': u'#/definitions/misc/multiline_string'},
                                                         u'text': {u'$ref': u'#/definitions/misc/multiline_string'}},
                                         u'required': [u'output_type',
                                                       u'prompt_number'],
                                         u'type': u'object'},
                              u'raw_cell': {u'additionalProperties': False,
                                            u'description': u'Notebook raw nbconvert cell.',
                                            u'properties': {u'cell_type': {u'description': u'String identifying the type of cell.',
                                                                           u'enum': [u'raw']},
                                                            u'metadata': {u'additionalProperties': True,
                                                                          u'description': u'Cell-level metadata.',
                                                                          u'properties': {u'format': {u'description': u'Raw cell metadata format for nbconvert.',
                                                                                                      u'type': u'string'},
                                                                                          u'name': {u'$ref': u'#/definitions/misc/metadata_name'},
                                                                                          u'tags': {u'$ref': u'#/definitions/misc/metadata_tags'}},
                                                                          u'type': u'object'},
                                                            u'source': {u'$ref': u'#/definitions/misc/source'}},
                                            u'required': [u'cell_type',
                                                          u'source'],
                                            u'type': u'object'},
                              u'stream': {u'additionalProperties': False,
                                          u'description': u'Stream output from a code cell.',
                                          u'properties': {u'output_type': {u'description': u'Type of cell output.',
                                                                           u'enum': [u'stream']},
                                                          u'stream': {u'description': u'The stream type/destination.',
                                                                      u'type': u'string'},
                                                          u'text': {u'$ref': u'#/definitions/misc/multiline_string',
                                                                    u'description': u"The stream's text output, represented as an array of strings."}},
                                          u'required': [u'output_type',
                                                        u'stream',
                                                        u'text'],
                                          u'type': u'object'},
                              u'worksheet': {u'additionalProperties': False,
                                             u'properties': {u'cells': {u'description': u'Array of cells of the current notebook.',
                                                                        u'items': {u'oneOf': [{u'$ref': u'#/definitions/raw_cell'},
                                                                                              {u'$ref': u'#/definitions/markdown_cell'},
                                                                                              {u'$ref': u'#/definitions/heading_cell'},
                                                                                              {u'$ref': u'#/definitions/code_cell'}],
                                                                                   u'type': u'object'},
                                                                        u'type': u'array'},
                                                             u'metadata': {u'description': u'metadata of the current worksheet',
                                                                           u'type': u'object'}},
                                             u'required': [u'cells']}},
             u'description': u'IPython Notebook v3.0 JSON schema.',
             u'properties': {u'metadata': {u'additionalProperties': True,
                                           u'description': u'Notebook root-level metadata.',
                                           u'properties': {u'kernel_info': {u'description': u'Kernel information.',
                                                                            u'properties': {u'codemirror_mode': {u'description': u'The codemirror mode to use for code in this language.',
                                                                                                                 u'type': u'string'},
                                                                                            u'language': {u'description': u'The programming language which this kernel runs.',
                                                                                                          u'type': u'string'},
                                                                                            u'name': {u'description': u'Name of the kernel specification.',
                                                                                                      u'type': u'string'}},
                                                                            u'required': [u'name',
                                                                                          u'language'],
                                                                            u'type': u'object'},
                                                           u'signature': {u'description': u'Hash of the notebook.',
                                                                          u'type': u'string'}},
                                           u'type': u'object'},
                             u'nbformat': {u'description': u'Notebook format (major number). Incremented between backwards incompatible changes to the notebook format.',
                                           u'maximum': 3,
                                           u'minimum': 3,
                                           u'type': u'integer'},
                             u'nbformat_minor': {u'description': u'Notebook format (minor number). Incremented for backward compatible changes to the notebook format.',
                                                 u'minimum': 0,
                                                 u'type': u'integer'},
                             u'orig_nbformat': {u'description': u'Original notebook format (major number) before converting the notebook between versions.',
                                                u'minimum': 1,
                                                u'type': u'integer'},
                             u'orig_nbformat_minor': {u'description': u'Original notebook format (minor number) before converting the notebook between versions.',
                                                      u'minimum': 0,
                                                      u'type': u'integer'},
                             u'worksheets': {u'description': u'Array of worksheets',
                                             u'items': {u'$ref': u'#/definitions/worksheet'},
                                             u'type': u'array'}},
             u'required': [u'metadata',
                           u'nbformat_minor',
                           u'nbformat',
                           u'worksheets'],
             u'type': u'object'}
    
        On instance:
            {u'cells': [],
             u'metadata': {},
             u'nbformat': 3,
             u'nbformat_minor': 0,
             u'worksheets': [{u'cells': [{u'cell_type': u'code',
                                          u'execution_count': None,
                                          u'input': u'%matplotlib inline',
                                          u'language': u'python',
                                          u'metadata': {},
                                          u'outputs': []},
                                         {u'cell_type': u'code',
                                          u'execution_count': None,
                                          u'input': u'',
                                          u'language': u'python',
                                          u'metadata': {},
                                          u'outputs': []},
                                         {u'cell_type': u'code',
                                          u'execution_count': None,
                                          u'input': u'',
                                          u'language': u'python',
                                          u'metadata': {},
                                          u'outputs': []}]}]}
    [W 21:25:30.393 NotebookApp] Notebook test.ipynb is not trusted
    

    In Pycharm

    /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /usr/local/bin/ipython notebook --no-browser --ip localhost --port 8889
    [I 21:18:54.055 NotebookApp] Serving notebooks from local directory: /Users/yangyy/GitHub/Signal&System
    [I 21:18:54.055 NotebookApp] 0 active kernels 
    [I 21:18:54.055 NotebookApp] The IPython Notebook is running at: http://localhost:8889/
    [I 21:18:54.056 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [W 21:18:56.558 NotebookApp] 404 GET /api (127.0.0.1) 27.47ms referer=None
    [I 21:18:56.589 NotebookApp] Kernel started: 2ff0bf8f-4351-4423-a867-23a698f4b820
    [W 21:18:56.594 NotebookApp] 404 GET /api/kernels/2ff0bf8f-4351-4423-a867-23a698f4b820/iopub (127.0.0.1) 1.52ms referer=None
    [W 21:18:56.596 NotebookApp] 404 GET /api/kernels/2ff0bf8f-4351-4423-a867-23a698f4b820/shell (127.0.0.1) 1.16ms referer=None
    [W 21:18:56.690 NotebookApp] 404 GET /api (127.0.0.1) 2.05ms referer=None
    [I 21:18:56.703 NotebookApp] Kernel started: d1e16c68-352d-4d1a-89ed-9548a666f9ab
    [W 21:18:56.712 NotebookApp] 404 GET /api/kernels/d1e16c68-352d-4d1a-89ed-9548a666f9ab/shell (127.0.0.1) 2.61ms referer=None
    [W 21:18:56.715 NotebookApp] 404 GET /api/kernels/d1e16c68-352d-4d1a-89ed-9548a666f9ab/iopub (127.0.0.1) 1.78ms referer=None
    [I 21:20:29.566 NotebookApp] Kernel restarted: d1e16c68-352d-4d1a-89ed-9548a666f9ab
    [W 21:20:38.117 NotebookApp] 404 GET /api (127.0.0.1) 2.99ms referer=None
    [I 21:20:38.132 NotebookApp] Kernel started: 792636bb-8fda-4d26-9f4f-c92a799ef23c
    [W 21:20:38.138 NotebookApp] 404 GET /api/kernels/792636bb-8fda-4d26-9f4f-c92a799ef23c/shell (127.0.0.1) 2.28ms referer=None
    [W 21:20:38.140 NotebookApp] 404 GET /api/kernels/792636bb-8fda-4d26-9f4f-c92a799ef23c/iopub (127.0.0.1) 1.26ms referer=None
    

    Things are working fine when I use the browser enter image description here

    Anyone's run into the same problem?

  • Luís Telles
    Luís Telles almost 7 years
    Well, I tried this solution but it did not work for me. I'm using PyCharm Community Edition 2016.2.3. I was using IPython 5.3.0 and uninstalled it with conda remove IPython (I'm using anaconda2). Then I installed IPython 3.2.3 with conda install 'ipython<4'. Tried to use the notebook and nothing ran again. Then I tried conda install jupyter but it needed to update IPython to the latest version. Couldn't install jupyter without updating IPython, even with --no-update-dependencies option.
  • Eric Leschinski
    Eric Leschinski almost 5 years
    Programmers got tired of fixing code that is broken intentionally every 3 to 7 months, I think python 4.2 was the last straw. Now it's just broken. By the time developers fix it, Python 8.1 break even that.