spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.25k stars 1.6k forks source link

LSP server does never activate after update to Spyder 6 from pip (icon is rotating forever in the taskbar) #21780

Closed hprodh closed 7 months ago

hprodh commented 7 months ago

Problem Description

What steps reproduce the problem?

  1. Probably just upgrade spyder to v6 with pip
  2. ????

Paste Traceback/Error Below (if applicable)

Launching Spyder in verbose debug mode with : $ spyder --debug-info verbose

-> yields the following error at some point :

""""

2024-02-08 15:03:27,409 [DEBUG] [spyder.plugins.completion.providers.languageserver.client] -> python Response error: {'code': -32602, 'message': " ValueError: Plugin already registered: pylsp_black=<module 'pylsp_black.plugin' from '/home/user/.local/lib/python3.10/site-packages/pylsp_black/plugin.py'>\n { 'black': <module 'pylsp_black.plugin' from '/home/user/.local/lib/python3.10/site-packages/pylsp_black/plugin.py'>, 'autopep8': <module 'pylsp.plugins.autopep8_format' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/autopep8_format.py'>, 'flake8': <module 'pylsp.plugins.flake8_lint' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/flake8_lint.py'>, 'folding': <module 'pylsp.plugins.folding' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/folding.py'>, 'jedi_completion': <module 'pylsp.plugins.jedi_completion' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/jedi_completion.py'>, 'jedi_definition': <module 'pylsp.plugins.definition' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/definition.py'>, 'jedi_highlight': <module 'pylsp.plugins.highlight' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/highlight.py'>, 'jedi_hover': <module 'pylsp.plugins.hover' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/hover.py'>, 'jedi_references': <module 'pylsp.plugins.references' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/references.py'>, 'jedi_rename': <module 'pylsp.plugins.jedi_rename' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/jedi_rename.py'>, 'jedi_signature_help': <module 'pylsp.plugins.signature' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/signature.py'>, 'jedi_symbols': <module 'pylsp.plugins.symbols' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/symbols.py'>, 'mccabe': <module 'pylsp.plugins.mccabe_lint' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/mccabe_lint.py'>, 'preload': <module 'pylsp.plugins.preload_imports' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/preload_imports.py'>, 'pycodestyle': <module 'pylsp.plugins.pycodestyle_lint' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/pycodestyle_lint.py'>, 'pydocstyle': <module 'pylsp.plugins.pydocstyle_lint' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/pydocstyle_lint.py'>, 'pyflakes': <module 'pylsp.plugins.pyflakes_lint' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/pyflakes_lint.py'>, 'pylint': <module 'pylsp.plugins.pylint_lint' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/pylint_lint.py'>, 'rope_autoimport': <module 'pylsp.plugins.rope_autoimport' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/rope_autoimport.py'>, 'rope_completion': <module 'pylsp.plugins.rope_completion' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/rope_completion.py'>, 'rope_rename': <module 'pylsp.plugins.rope_rename' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/rope_rename.py'>, 'yapf': <module 'pylsp.plugins.yapf_format' from '/home/user/.local/lib/python3.10/site-packages/pylsp/plugins/yapf_format.py'> } ", 'data': {'traceback': [' File "/home/user/.local/lib/python3.10/site-packages/pylsp_jsonrpc/endpoint.py", line 117, in consume\n self._handle_request(message[\'id\'], message[\'method\'], message.get(\'params\'))\n', ' File "/home/user/.local/lib/python3.10/site-packages/pylsp_jsonrpc/endpoint.py", line 197, in _handle_request\n handler_result = handler(params)\n', ' File "/home/user/.local/lib/python3.10/site-packages/pylsp_jsonrpc/dispatchers.py", line 25, in handler\n return method(**(params or {}))\n', ' File "/home/user/.local/lib/python3.10/site-packages/pylsp/python_lsp.py", line 322, in m_initialize\n self.config = config.Config(\n', ' File "/home/user/.local/lib/python3.10/site-packages/pylsp/config/config.py", line 89, in init\n self._pm.load_setuptools_entrypoints(PYLSP)\n', ' File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 288, in load_setuptools_entrypoints\n self.register(plugin, name=ep.name)\n', ' File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 91, in register\n raise ValueError(\n']}}

"""

==>> PROBLEM HAS BEEN SOLVED WITH :

& python3 -m pip uninstall python-lsp-black & python3 -m pip install python-lsp-black

hprodh commented 7 months ago

Update :

Actually the reinstallation of python-lsp-black did not provide the version required by Spyder 6. I could reinstall the required version but the problem of the LSP server not working comes back. Keeping python-lsp-black to a previous version (or removed) yields an error pop-up at the start of Spyder 6 saying the module is required, yet I can just click OK and process with my coding work, with the automatic error introspection working well.

ccordoba12 commented 7 months ago

Hey @hprodh, thanks for reporting. From the traceback above, it seems you're mixing packages installed locally, like this

'data': {'traceback': [' File "/home/user/.local/lib/python3.10/site-packages/pylsp_jsonrpc/endpoint.py"

with others installed in /usr/local, like this

' File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 91, in register\n raise ValueError(\n']}}

This an installation method we don't support precisely because it can lead to this kind of errors.

So, my recommendation for you is to remove this folder:

/home/user/.local/lib/python3.10

and install Spyder in a virtualenv, as described in our documentation:

http://docs.spyder-ide.org/current/installation.html#using-pip

hprodh commented 4 months ago

Thank you @ccordoba12 . Yet I keep working on spyder installed from pip with no virtualenv or anaconda. I am just reporting here, in case it is useful for someone : Spyder 5.5.3 is working with python-lsp-black uninstalled, just showing an error message at the start. With python-lsp-black installed, or with spyder 5.5.4 or 6x, python LSP server never starts.

ccordoba12 commented 4 months ago

With python-lsp-black installed, or with spyder 5.5.4 or 6x, python LSP server never starts.

That's because you're basically refusing to properly install Spyder and it's not going to change. So, please refrain from reporting that problem again (I really don't understand why you insist on this).

hprodh commented 6 days ago

I understand... I keep install spyder with pip without creating a virtual env because I don't want to create multiple copies of packages with different versions, I am not used to work with venv and a bit scared by the possible confusion between packages. Also I want to be sure the scripts I develop and test within spyder work the same way when called from command-line. Also, I want users of my codes to be able to setup spyder without administrative privileges.

I additionnally want to report that spyder 6 works on ubuntu 24.04 when installed from pip after fresh install. For this I needed first to rename the file using (with privileges) : $ mv /usr/lib/python3.12/EXTERNALLY-MANAGED /usr/lib/python3.12/EXTERNALLY-MANAGED.old This way, if I understood correctly, "installation of externally managed packages are not prevented but install to the home folder". On some non-fresh install of Ubuntu 24.04, I had to remove (with apt remove) the packages related to spyder which were installed by apt, before installing spyder from pip.

I know this is not the right way of installing spyder yet I just report here that it works this way in case it is useful for someone else (spyder 6.0.1 works as well). No need to re-open the issue.