On Thu, May 25, 2023 at 08:03:19PM +0100, Julian Gilbey wrote: > On Thu, May 25, 2023 at 09:25:50AM -0700, Brian Vaughan wrote: > > # Spyder, Help > Dependencies > > [...] > > pylsp >=1.7.1;<1.8.0 : 1.7.1 (OK) > > pylsp_black >=1.2.0 : None (NOK) > > Hi Brian, > > Thanks for sending all this through. This is so weird. > [...] > All looks normal here. > > I am utterly mystified why spyder is not finding pylsp_black. I'll > have a think about it and get back to you.
If you're able to do the following tests, it might help shed some light on what's going wrong. The attached is a patch for the file /usr/lib/python3/dist-packages/spyder/dependencies.py to give more debugging output. Please apply the patch; you can do this by saving the patch to a file, say /tmp/dependencies.py.diff, then running the commands: cd /usr/lib/python3/dist-packages/spyder/dependencies.py patch --backup < /tmp/dependencies.py.diff where the "--backup" option saves a copy of the original dependencies.py file as dependencies.py.orig. Once this patch is applied, start spyder from a terminal using the command: spyder --debug-info verbose and let it run at least until it gives the warning message about pylsp_black not being found, then quit spyder. There will be lots of messages written to the terminal, but they will also be saved in the file .config/spyder-py3/spyder-debug.log Have a look through this file for "pylsp_black". Here's what I see: 2023-05-29 11:00:24,689 [DEBUG] [spyder.dependencies] -> Dependency(pylsp_black, python_lsp_black) starting 2023-05-29 11:00:24,931 [DEBUG] [spyder.dependencies] -> Dependency: get_module_version returned None for pylsp_black 2023-05-29 11:00:24,932 [DEBUG] [spyder.dependencies] -> Dependency: get_package_version returned 1.2.1 for pylsp_black I'm guessing you'll get something quite different, probably with some further debugging output following it (perhaps "Dependency: exception raised..." followed by "Dependency: when exception raised..."). If you're able to do this experiment, please could you send me these lines of the log file. (I don't imagine that I would need any more of the log file at this point.) I do hope this will help to find the source of the problem! Best wishes, Julian
--- dependencies.py.orig 2023-02-23 10:59:49.000000000 +0000 +++ dependencies.py 2023-05-29 10:59:40.056580272 +0100 @@ -10,6 +10,7 @@ import os import os.path as osp import sys +import logging # Local imports from spyder.config.base import _, is_pynsist, running_in_ci, running_in_mac_app @@ -17,6 +18,8 @@ HERE = osp.dirname(osp.abspath(__file__)) +logger = logging.getLogger(__name__) + # ============================================================================= # Kind of dependency # ============================================================================= @@ -319,21 +322,37 @@ # * Package name: python-lsp-black. # * Distribution name: python_lsp_black self.distribution_name = self.package_name.replace('-', '_') - + logger.debug( + "Dependency(%s, %s) starting", modname, self.distribution_name + ) + if installed_version is None: try: self.installed_version = programs.get_module_version(modname) + logger.debug( + "Dependency: get_module_version returned %s for %s", + self.installed_version, modname + ) if not self.installed_version: # Use get_package_version and the distribution name # because there are cases for which the version can't # be obtained from the module (e.g. pylsp_black). self.installed_version = programs.get_package_version( self.distribution_name) - except Exception: + logger.debug( + "Dependency: get_package_version returned %s for %s", + self.installed_version, modname + ) + except Exception as exc: # NOTE: Don't add any exception type here! # Modules can fail to import in several ways besides # ImportError self.installed_version = None + logger.debug("Dependency: exception raised: %s", exc) + logger.debug( + "Dependency: when exception raised: sys.path = %s", + sys.path + ) else: self.installed_version = installed_version