lsp-pyright 提示 “Server pyright:84540/starting exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n) ”

尝试在win11环境下配置emacs28 使用lsp-pyright配置python开发环境,配置文件都是东抄一点,西抄一点,出了问题,我自己解决不了……


(use-package lsp-pyright
  :ensure t
  :hook (python-mode . (lambda ()
                         (setq lsp-diagnostics-provider :none) ;; don't use 'lsp as default flycheck checker, this will turn off the flycheck auto-start too.
                         (setq flycheck-checker 'python-pyright) ;; use 'python-pyright instead as python checker.
                         (global-flycheck-mode) ;; enable flycheck manually.
                         (require 'lsp-pyright) ;; use lsp-pyright lsp
                         (lsp-deferred))))

(provide 'init-python)

使用 pip install pyright 使用 npm install -g pyright

pyright::stderr 的报错信息:

Traceback (most recent call last):

  File "D:\Code\Python310\lib\runpy.py", line 196, in _run_module_as_main

    return _run_code(code, main_globals, None,

  File "D:\Code\Python310\lib\runpy.py", line 86, in _run_code

    exec(code, run_globals)

  File "d:\Code\Python310\Scripts\pyright-langserver.exe\__main__.py", line 7, in <module>

  File "D:\Code\Python310\lib\site-packages\pyright\langserver.py", line 57, in entrypoint

    sys.exit(main(*sys.argv[1:]))

  File "D:\Code\Python310\lib\site-packages\pyright\langserver.py", line 26, in main

    return run(*args, **kwargs).returncode

  File "D:\Code\Python310\lib\site-packages\pyright\langserver.py", line 51, in run

    raise RuntimeError(f'Expected language server entrypoint: {binary} to exist')

RuntimeError: Expected language server entrypoint: C:\Users\YAO\AppData\Local\Temp\pyright-python-langserver.YAO\node_modules\pyright\langserver.index.js to exist


Process pyright stderr finished

C:\Users\YAO\AppData\Local\Temp\pyright-python-langserver.YAO 这个文件夹我看过了,是个空的文件夹,但是不知道这个文件夹是干啥的,也不明白如何处理? 有遇到类似问题的人吗?请指教指教吧。

是因为没有找到 pyright-langserver ?

pip install pyright 这个是干嘛的?卸载自己安装的,直接用lsp-install-server 安装pyright。

原来是这样…… 多谢你的帮助,看起来正常了。 多谢多谢。

不客气,解决就好。