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.

"Go to definition" causes error in Python 3.6

See original GitHub issue

Description

What steps will reproduce the problem?

Any use of “Go to definition” in Windows with Spyder 4.1.5 raises this error.

Traceback

  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1440, in handle_go_to_definition
    def_range = position['range']
TypeError: list indices must be integers or slices, not str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\ProgramData\Anaconda3\lib\logging\__init__.py", line 992, in emit
    msg = self.format(record)
  File "c:\ProgramData\Anaconda3\lib\logging\__init__.py", line 838, in format
    return fmt.format(record)
  File "c:\ProgramData\Anaconda3\lib\logging\__init__.py", line 575, in format
    record.message = record.getMessage()
  File "c:\ProgramData\Anaconda3\lib\logging\__init__.py", line 338, in getMessage
    msg = msg % self.args
ValueError: incomplete format
Call stack:
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 223, in <module>
    main()
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 219, in main
    mainwindow.main()
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3651, in main
    mainwindow = run_spyder(app, options, args)
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3567, in run_spyder
    app.exec_()
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\languageserver\client.py", line 497, in on_msg_received
    self.req_reply[req_id](None, {'params': []})
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\languageserver\plugin.py", line 549, in receive_response
    self.COMPLETION_CLIENT_NAME, req_id, response)
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\plugin.py", line 123, in receive_response
    self.howto_send_to_codeeditor(req_id)
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\plugin.py", line 171, in howto_send_to_codeeditor
    self.skip_and_send_to_codeeditor(req_id)
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\plugin.py", line 205, in skip_and_send_to_codeeditor
    self.gather_and_send_to_codeeditor(request_responses)
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\plugin.py", line 273, in gather_and_send_to_codeeditor
    response_instance.handle_response(req_type, responses)
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1019, in handle_response
    handler(params)
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1457, in handle_go_to_definition
    "Error when processing go to definition")
  File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1050, in log_lsp_handle_errors
    logger.error('%', 1, stack_info=True)
Message: '%'
Arguments: (1,)

Versions

  • Spyder version: 4.1.5
  • Python version: 3.6.4
  • Qt version: 5.9.6
  • PyQt5 version: 5.9.2
  • Operating System: Windows 10

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  0.5.2 (OK)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.16.1 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  0.7.0 (OK)
paramiko >=2.4.0               :  2.4.2 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.4 (OK)
psutil >=5.3                   :  5.7.2 (OK)
pygments >=2.0                 :  2.2.0 (OK)
pylint >=1.0                   :  1.8.2 (OK)
pyls >=0.34.0;<1.0.0           :  0.34.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  0.7.2 (OK)
qtconsole >=4.6.0              :  4.7.6 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.2.1 (OK)
spyder_kernels >=1.9.4;<1.10.0 :  1.9.4 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  19.0.1 (OK)

# Optional:
cython >=0.21                  :  0.27.3 (OK)
matplotlib >=2.0.0             :  2.2.2 (OK)
numpy >=1.7                    :  1.18.1 (OK)
pandas >=0.13.1                :  0.24.2 (OK)
scipy >=0.17.0                 :  1.4.1 (OK)
sympy >=0.7.3                  :  1.1.1 (OK)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, Sep 19, 2020

Python version: 3.6.4

Maybe the issue is with Python 3.6.

@dalthviz, could you try to reproduce this on Windows?

0reactions
dalthvizcommented, Sep 21, 2020

Checking a little bit more seems like an update to jedi 0.17.2 fixes the issues (seems like jedi 0.17.1 has an issue when running under Python 3.6):

import jedi
source = '''
import json
json.lo'''
script = jedi.Script(source, path='example.py')
completions = script.complete(3, len('json.lo'))
Traceback (most recent call last):

  File "C:\Users\Daniel\Anaconda3\envs\py36\lib\site-packages\jedi\inference\compiled\subprocess\__init__.py", line 261, in _send
    is_exception, traceback, result = pickle_load(self._get_process().stdout)

  File "C:\Users\Daniel\Anaconda3\envs\py36\lib\site-packages\jedi\_compatibility.py", line 396, in pickle_load
    return pickle.load(file, encoding='bytes')

EOFError: Ran out of input


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "C:\Users\Daniel\Anaconda3\envs\py36\lib\site-packages\jedi\api\environment.py", line 75, in _get_subprocess
    info = self._subprocess._send(None, _get_info)

  File "C:\Users\Daniel\Anaconda3\envs\py36\lib\site-packages\jedi\inference\compiled\subprocess\__init__.py", line 273, in _send
    stderr,

InternalError: The subprocess C:\Users\Daniel\Anaconda3\envs\py36\python.exe has crashed (EOFError('Ran out of input',), stderr=).


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "<ipython-input-1-ef826d01cd16>", line 5, in <module>
    script = jedi.Script(source, path='example.py')

  File "C:\Users\Daniel\Anaconda3\envs\py36\lib\site-packages\jedi\api\__init__.py", line 185, in __init__
    project, environment=environment, script_path=self.path

  File "C:\Users\Daniel\Anaconda3\envs\py36\lib\site-packages\jedi\inference\__init__.py", line 90, in __init__
    self.compiled_subprocess = environment.get_inference_state_subprocess(self)

  File "C:\Users\Daniel\Anaconda3\envs\py36\lib\site-packages\jedi\api\environment.py", line 114, in get_inference_state_subprocess
    return InferenceStateSubprocess(inference_state, self._get_subprocess())

  File "C:\Users\Daniel\Anaconda3\envs\py36\lib\site-packages\jedi\api\environment.py", line 80, in _get_subprocess
    exc))

InvalidPythonEnvironment: Could not get version information for 'C:\\Users\\Daniel\\Anaconda3\\envs\\py36\\python.exe': InternalError("The subprocess C:\\Users\\Daniel\\Anaconda3\\envs\\py36\\python.exe has crashed (EOFError('Ran out of input',), stderr=).",)

I think the issue is related with davidhalter/jedi#1627

With Jedi 0.17.2 everything (as far as I tested) works as expected. Maybe we need to change the Jedi dependency version from =0.17.1 to = 0.17.2 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

variable defined in a class gives an error in Python 3 [duplicate]
This following simple code gives an error in Python 3.6 (but OK in 2.7): class XY: pre = '' z = [pre +...
Read more >
8. Errors and Exceptions — Python 3.11.1 documentation
The error is caused by (or at least detected at) the token preceding the arrow: in the example, the error is detected at...
Read more >
Built-in Exceptions — Python 3.11.1 documentation
In Python, all exceptions must be instances of a class that derives from BaseException . In a try statement with an except clause...
Read more >
What's New In Python 3.6 — Python 3.11.1 documentation
The new PYTHONMALLOC environment variable can now be used to debug the interpreter memory allocation and access errors. Significant improvements in the standard ......
Read more >
Exception Handling — Python 3.11.1 documentation
Most C API functions don't clear this on success, but will set it to indicate the cause of the error on failure. Most...
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