question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError when opening new notebook

See original GitHub issue

I followed the steps outlined in readme, but it seems that pyls can’t find source files I get this error:

Example Server: 2019-09-12 10:35:37,818 UTC - ERROR - pyls_jsonrpc.endpoint - Failed to handle notification textDocument/didChange: {'textDocument': {'uri': 'file:///test.ipynb.python', 'version': 1}, 'contentChanges': [{'text': 'import pandas as pd\n\n\npd.\n'}]}
Traceback (most recent call last):                                                                                                                                                                                    File "/usr/local/miniconda3/envs/notebook/lib/python3.7/site-packages/pyls_jsonrpc/endpoint.py", line 142, in _handle_notification
    handler_result = handler(params)
  File "/usr/local/miniconda3/envs/notebook/lib/python3.7/site-packages/pyls_jsonrpc/dispatchers.py", line 23, in handler                                                                                               return method(**(params or {}))
  File "/usr/local/miniconda3/envs/notebook/lib/python3.7/site-packages/pyls/python_ls.py", line 281, in m_text_document__did_change
    version=textDocument.get('version')                                                                                                                                                                               File "/usr/local/miniconda3/envs/notebook/lib/python3.7/site-packages/pyls/workspace.py", line 77, in update_document
    self._docs[doc_uri].apply_change(change)
KeyError: 'file:///test.ipynb.python'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
krassowskicommented, Nov 1, 2019

Thank you. It’s just that pyls was not written with supporting notebooks in mind, if the extension otherwise works as expected then there is nothing to worry about (right now) - please treat it as a false positive, unless you experience other issues (i.e. some functionalities we already support not working as expected).

I will work on fixing this message later on.

0reactions
shreyasgmcommented, Nov 1, 2019

Hi, thank you for your work on this extension. I think this error might have resurfaced - I’m getting the following error on two separate machines:

2019-11-01 08:49:54,265 UTC - ERROR - pyls_jsonrpc.endpoint - Failed to handle notification textDocument/didChange: {u'contentChanges': [{u'text': <text_hidden>}], u'textDocument': {u'version': 0, u'uri': u'file:///Users/shg309/<path_hidden>.ipynb'}}
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pyls_jsonrpc/endpoint.py", line 142, in _handle_notification
    handler_result = handler(params)
  File "/usr/local/lib/python2.7/site-packages/pyls_jsonrpc/dispatchers.py", line 23, in handler
    return method(**(params or {}))
  File "/usr/local/lib/python2.7/site-packages/pyls/python_ls.py", line 279, in m_text_document__did_change
    version=textDocument.get('version')
  File "/usr/local/lib/python2.7/site-packages/pyls/workspace.py", line 77, in update_document
    self._docs[doc_uri].apply_change(change)
KeyError: u'file:///Users/shg309/<path_hidden>.ipynb'

Screenshot from developer console: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Key Error - Jupyter Notebook - Stack Overflow
I have started to learn pandas. I am using Jupyter notebook. I have imported the test data file -Weather I read the file...
Read more >
Key error on Jupyter Notebook · Issue #557 - GitHub
from ipyleaflet import Map, Velocity, TileLayer, basemaps import xarray as xr import os if not os.path.exists('wind-global.nc'): url ...
Read more >
How to fix Python KeyError Exceptions in simple steps?
A Python KeyError is raised when you try to access an invalid key in a dictionary. In simple terms, when you see a...
Read more >
KeyError: 'loggers' when trying to open Jupyter - PyXLL
When you try to open a Jupyter notebook if you get the following error this this article explains what you need to do...
Read more >
keyerror in Python – How to Fix Dictionary Error
When working with dictionaries in Python, a KeyError gets raised when you try to access an item that doesn't exist in a Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found