Spyder: Go to definition not working on local packages

Created on 22 Jul 2020  路  10Comments  路  Source: spyder-ide/spyder

Issue Report Checklist

  • [X ] Searched the issues page for similar reports
  • [X] Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • [X] Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • [X] Could not reproduce inside jupyter qtconsole (if console-related)
  • [X] Tried basic troubleshooting (if a bug/error)

    • [X] Restarted Spyder

    • [X] Reset preferences with spyder --reset

    • [X] Reinstalled the latest version of Anaconda

    • [X] Tried the other applicable steps from the Troubleshooting Guide

  • [X] Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

Go to definition not working on local packages

What steps reproduce the problem?

  1. Assuming a main file: ./main.py
    from v24.funcs import reset_logger
    reset_logger()

  2. And a ./v24/funcs.py file:
    def reset_logger():
    print('Hello')

  3. Go to definition in main.py reset_logger() doesn't do anything.
    Used to work fine in versions prior to 4.1.4.
    It still works for definitions in the same file (main.py) or external Python packages (numpy etc)

What is the expected output? What do you see instead?

Open ./v24/funcs.py in the editor and place the cursor on the function definition

Paste Traceback/Error Below (if applicable)


PASTE TRACEBACK HERE

Versions

  • Spyder version: 4.1.4
  • Python version: 3.6.10
  • Qt version: 5.9.7
  • PyQt version: 5.9.2
  • Operating System name/version: Linus 3.10.0

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.5.0 (OK)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.13.0 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
keyring                        :  None (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  1.1.0 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=1.0                   :  2.5.3 (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.5 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.1.2 (OK)
spyder_kernels >=1.9.2;<1.10.0 :  1.9.2 (OK)
watchdog                       :  None (OK)
xdg >=0.26                     :  0.26 (OK)
zmq >=17                       :  19.0.1 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  3.1.0 (OK)
numpy >=1.7                    :  1.18.5 (OK)
pandas >=0.13.1                :  None (OK)
scipy >=0.17.0                 :  1.4.1 (OK)
sympy >=0.7.3                  :  None (OK)
Editor Reproduced Bug

All 10 comments

Hi @liavassif thanks for the feedback. I was unable to reproduce this using Python 3.7. As a workaround, if you want to use Spyder 4.1.4, could you try to install Spyder in an env with Python 3.7?

I think that this could be caused do to the update to jedi 0.17 in our dependencies (I think it doesn't totally support python 3.6 well). What do you think @ccordoba12 ?

Hi @liavassif thanks for the feedback. I was unable to reproduce this using Python 3.7. As a workaround, if you want to use Spyder 4.1.4, could you try to install Spyder in an env with Python 3.7?

I think that this could be caused do to the update to jedi 0.17 in our dependencies (I think it doesn't totally support python 3.6 well). What do you think @ccordoba12 ?

I've tried a new env with Python 3.7.7. Still does not work.
I'm not using any project in Spyder. Could this be relevant?

Versions

  • Spyder version: 4.1.4
  • Python version: 3.7.7
  • Qt version: 5.9.7
  • PyQt version: 5.9.2
  • Operating System name/version: Linux 3.10.0

Dependencies

# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.5.0 (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)
keyring                        :  None (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  1.1.0 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=1.0                   :  2.4.4 (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.5 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.1.2 (OK)
spyder_kernels >=1.9.2;<1.10.0 :  1.9.2 (OK)
watchdog                       :  None (OK)
xdg >=0.26                     :  0.26 (OK)
zmq >=17                       :  19.0.1 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  None (OK)
numpy >=1.7                    :  None (OK)
pandas >=0.13.1                :  None (OK)
scipy >=0.17.0                 :  None (OK)
sympy >=0.7.3                  :  None (OK)

Thanks for the response @liavassif actually checking again I'm being able to reproduce this. We will be checking this for a future release :+1:

Note: @liavassif as a workaround you will need to wrap your code base as a project (using the New Project... > Existing directory)

Note: @liavassif as a workaround you will need to wrap your code base as a project (using the New Project... > Existing directory)

This works. Thanks!

Same experience for python 3.8.5. Does the latest release (spyder 4.1.5) possibly address this issue?

Updated to it and still can't show local packages in the editor when i "go to definition". To be fair in the changelog there is no referrence to the current issue # but was wondering whether there is a change in settings that is necessary.

Hi @tryfonch there is not a fix for this yet, sorry :/ when someone submits a fix this issue will get referenced in the respective PR and closed after the merge of the fix.

However, now that I think in this maybe what is happening is that the path where you are doing your local package needs to be added to the PYTHONPATH. For that, you can go to Tools > PYTHONPATH manager and there you can add the root path of your package (that's part of what opening a project does inside Spyder and probably is why opening the package as a project enables the go to definition). If you can try this approach let us know if works @tryfonch :)

@dalthviz when i go to Tools > PYTHONPATH manager what i get is an empty box:

Capture

However my local paths are already added to PYTHONPATH and whenever i import files that exist in those paths they run fine in the spyder console.

Capture

This is on a fresh conda installation (version 4.8.4).

Thanks @tryfonch for the feedback! Surely this new info will help us to implement a fix for this :+1:

Edit: pinged the incorrect user 馃槄

Note: To make this work, we probably need to add the current document path to sys.path here:

https://github.com/palantir/python-language-server/blob/464663300754708e4a557c036c753ee8aea7def4/pyls/workspace.py#L242

Was this page helpful?
0 / 5 - 0 ratings

Related issues

goanpeca picture goanpeca  路  3Comments

dalthviz picture dalthviz  路  3Comments

yogu220172 picture yogu220172  路  3Comments

cchu08 picture cchu08  路  3Comments

ok97465 picture ok97465  路  3Comments