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.

PyLSP fails to find package when launched from spyder.

See original GitHub issue

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

Under some conditions, pylsp will not find some library, but only when launched from spyder.

What steps reproduce the problem?

First, let’s create a dummy package:

  1. Create a folder called my package
  2. In that folder, create a folder called mypackage
  3. Create my package/setup.py with:
from distutils.core import setup

setup(name='mypackage',
      version='0.0',
      packages=['mypackage'],
     )
  1. Create my package/mypackage/__init__.py with:
def a():
    print(0)
  1. With the anaconda prompt, go to the my package folder and install with pip install --user -e .
  2. Open spyder
  3. Create a new file
  4. write import mypackage
  5. ctrl + click on mypackage to go to the definition
  6. nothing happens

This is annoying. WHat is strange is that if I then: 11. Open the anaconda prompt, start a new pylsp with: pylsp --tcp --host 127.0.0.1 --port 2088 12. Go to spyder settings > Completion and linting > Advanced 13. Enable advanced settings, set the port to 2088, check “This is an external server” 14. ctrl + click on mypackage to go to the definition 15. It goes to definition

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

I would expect pylsp to work even when launched from spyder. Instead it fails.

The failure is quite specific. I think but am not sure that it only happens with the pip --user option.

Versions

  • Spyder version: 5.x dev
  • Python version: 3.8.5
  • Qt version: 5.12.10
  • PyQt version: 5.12.3
  • Operating System name/version: Windows 10

Dependencies


# Mandatory:
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  3.0.4 (OK)
cloudpickle >=0.5.0           :  1.6.0 (OK)
cookiecutter >=1.6.0          :  1.7.2 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.6.0               :  7.19.0 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.0 (OK)
jellyfish >=0.7               :  None (OK)
jsonschema >=3.2.0            :  3.2.0 (OK)
keyring >=17.0.0              :  21.4.0 (OK)
nbconvert >=4.0               :  6.0.7 (OK)
numpydoc >=0.6.0              :  1.1.0 (OK)
paramiko >=2.4.0              :  2.7.2 (OK)
parso >=0.7.0;<0.9.0          :  0.8.2 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.7.2 (OK)
pygments >=2.0                :  2.7.2 (OK)
pylint >=2.5.0                :  2.6.0 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.2.2;<1.3.0          :  1.2.3 (OK)
pylsp_black >=1.0.0           :  None (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.2.0 (OK)
qtawesome >=1.0.2             :  1.0.2 (OK)
qtconsole >=5.1.0             :  5.1.0 (OK)
qtpy >=1.5.0                  :  1.9.0 (OK)
rtree >=0.9.7                 :  0.9.7 (OK)
setuptools >=49.6.0           :  58.2.0 (OK)
sphinx >=0.6.6                :  3.2.1 (OK)
spyder_kernels >=2.1.1;<2.2.0 :  2.2.0.dev0 (OK)
textdistance >=4.2.0          :  4.2.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  0.10.3 (OK)
zmq >=17                      :  19.0.2 (OK)

# Optional:
cython >=0.21                 :  0.29.21 (OK)
matplotlib >=2.0.0            :  3.4.2 (OK)
numpy >=1.7                   :  1.19.2 (OK)
pandas >=1.1.1                :  1.1.3 (OK)
scipy >=0.17.0                :  1.5.2 (OK)
sympy >=0.7.3                 :  1.6.2 (OK)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, Nov 6, 2021

So seems like this issue only happens when installing the package in the env that the default interpreter uses?

Ok, that’s great info @dalthviz! We’ll have to dig into the PyLSP logs to find what could be happening in this case.

0reactions
mrclarycommented, Dec 27, 2021

@impact27 @dalthviz, could #16429 or #16488 have a positive impact on this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Emergency CPR — Spyder 5 documentation
Is Spyder not launching at all? The steps on this section should hopefully get ... Check and repair/reset permissions, your disk, and OS...
Read more >
Spyder complains about missing dependency paramiko
Try: conda update paramiko. If it does not work: pip uninstall paramiko pip install pyqt5==5.12 pip install pyqtwebengine==5.12 pip install ...
Read more >
1979315 – Review Request: python-lsp-server
This package is consumed by editors (at the moment, only spyder). As far as I know, end user does not run this directly....
Read more >
pyls-spyder - PyPI
This package provides Spyder-specific extras for the Language Server Protocol (LSP) on Python, such as document symbol searching and others. Installing. To ...
Read more >
Python 3.9 missing python-language-server? - NixOS Discourse
do you know how spyder gets through Hydra without to be marked broken? ... Any package which fails to evaluate (e.g. spyder) will...
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