请问我的pyright为什么安装失败,lsp-bridge可以换成调用pylsp吗?

lsp-bridge必须使用pyright吗?我在init.el中改成 python-lsp-server 'pylsp 打开Python文件依然是提示启动pyright并失败。

我这里提示pyright、python-lsp-server、node 和npm都已经安装了,但直接运行pyright还是会出现和lsp-bridge一样的错误,请问是什么原因?要怎么处理?谢谢。

subprocess.CalledProcessError: Command '['e:\\lxs\\anaconda\\python.exe', '-m', 'nodeenv', 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pyright-python.Administrator\\env']' returned non-zero exit status 2.

完整的pyright::stderr信息如下:

 * Environment already exists: C:\Users\ADMINI~1\AppData\Local\Temp\pyright-python.Administrator\env
Traceback (most recent call last):
  File "e:\lxs\anaconda\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "e:\lxs\anaconda\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "e:\lxs\anaconda\Scripts\pyright-langserver.exe\__main__.py", line 7, in <module>
  File "e:\lxs\anaconda\lib\site-packages\pyright\langserver.py", line 57, in entrypoint
    sys.exit(main(*sys.argv[1:]))
  File "e:\lxs\anaconda\lib\site-packages\pyright\langserver.py", line 26, in main
    return run(*args, **kwargs).returncode
  File "e:\lxs\anaconda\lib\site-packages\pyright\langserver.py", line 37, in run
    version = node.latest('pyright')
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 133, in latest
    proc = run(
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 86, in run
    binary = _ensure_available(target)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 34, in _ensure_available
    return Binary(path=_ensure_node_env(target), strategy=Strategy.NODEENV)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 52, in _ensure_node_env
    _install_node_env()
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 79, in _install_node_env
    subprocess.run(args, check=True)
  File "e:\lxs\anaconda\lib\subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['e:\\lxs\\anaconda\\python.exe', '-m', 'nodeenv', 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pyright-python.Administrator\\env']' returned non-zero exit status 2.

Process pyright stderr finished
 * Environment already exists: C:\Users\ADMINI~1\AppData\Local\Temp\pyright-python.Administrator\env
Traceback (most recent call last):
  File "e:\lxs\anaconda\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "e:\lxs\anaconda\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "e:\lxs\anaconda\Scripts\pyright-langserver.exe\__main__.py", line 7, in <module>
  File "e:\lxs\anaconda\lib\site-packages\pyright\langserver.py", line 57, in entrypoint
    sys.exit(main(*sys.argv[1:]))
  File "e:\lxs\anaconda\lib\site-packages\pyright\langserver.py", line 26, in main
    return run(*args, **kwargs).returncode
  File "e:\lxs\anaconda\lib\site-packages\pyright\langserver.py", line 37, in run
    version = node.latest('pyright')
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 133, in latest
    proc = run(
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 86, in run
    binary = _ensure_available(target)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 34, in _ensure_available
    return Binary(path=_ensure_node_env(target), strategy=Strategy.NODEENV)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 52, in _ensure_node_env
    _install_node_env()
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 79, in _install_node_env
    subprocess.run(args, check=True)
  File "e:\lxs\anaconda\lib\subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['e:\\lxs\\anaconda\\python.exe', '-m', 'nodeenv', 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pyright-python.Administrator\\env']' returned non-zero exit status 2.

Process pyright stderr finished

安装信息如下:

Microsoft Windows [版本 10.0.17763.1098]
(c) 2018 Microsoft Corporation。保留所有权利。

e:\lxs>echo %PATH%
echo %PATH%
e:\lxs\Anaconda3;e:\lxs\Anaconda3\Library\mingw-w64\bin;e:\lxs\Anaconda3\Library\usr\bin;e:\lxs\Anaconda3\Library\bin;e:\lxs\Anaconda3\Scripts;c:\Windows\system32;c:\Windows;c:\Windows\System32\Wbem;c:\Windows\System32\WindowsPowerShell\v1.0;c:\Windows\System32\OpenSSH;c:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;c:\Program Files\Intel\Intel(R) Management Engine Components\DAL;c:\Program Files\Intel\WiFi\bin;c:\Program Files\Common Files\Intel\WirelessCommon;d:\Program Files\Gow\bin;e:\lxs\Git\cmd;c:\Users\Administrator\scoop\shims;e:\lxs\texlive\2020\bin\win32;c:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;d:\Program Files\GNU Octave\Octave-6.2.0;e:\lxs\linux\wsl-terminal;d:\Program Files\Tesseract-OCR;;d:\Program Files\R\R-4.1.2\bin\x64;d:\Program Files\R\R-4.1.2\bin;d:\Program Files\ripgrep;e:\lxs\anaconda;e:\lxs\anaconda\Library\mingw-w64\bin;e:\lxs\anaconda\Library\usr\bin;e:\lxs\anaconda\Library\bin;e:\lxs\anaconda\Scripts;d:\Program Files\Inkscape\bin;d:\Program Files\Microsoft VS Code\bin;d:\Program Files\poppler-0.68.0\bin;d:\Tencent\QQGameTempest\Hall.57734;e:\lxs\emacs-28.1\libexec\emacs\28.1\x86_64-w64-mingw32

e:\lxs>where pyright
where pyright
e:\lxs\anaconda\Scripts\pyright.exe

e:\lxs>ls e:\lxs\anaconda\Scripts\pyright*
ls e:\lxs\anaconda\Scripts\pyright*
e:\lxs\anaconda\Scripts\pyright-langserver.exe
e:\lxs\anaconda\Scripts\pyright-python-langserver.exe
e:\lxs\anaconda\Scripts\pyright-python.exe
e:\lxs\anaconda\Scripts\pyright.exe
e:\lxs\anaconda\Scripts\pyright.exe.deleteme

e:\lxs>pip install node npm
pip install node npm
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: node in .\anaconda\lib\site-packages (1.0)
Requirement already satisfied: npm in .\anaconda\lib\site-packages (0.1.1)
Requirement already satisfied: zope.deprecation in .\anaconda\lib\site-packages (from node) (4.4.0)
Requirement already satisfied: odict>=1.8.0 in .\anaconda\lib\site-packages (from node) (1.9.0)
Requirement already satisfied: zope.lifecycleevent in .\anaconda\lib\site-packages (from node) (4.4)
Requirement already satisfied: zope.deferredimport in .\anaconda\lib\site-packages (from node) (4.4)
Requirement already satisfied: zope.component in .\anaconda\lib\site-packages (from node) (5.0.1)
Requirement already satisfied: setuptools in .\anaconda\lib\site-packages (from node) (52.0.0.post20210125)
Requirement already satisfied: plumber>=1.5 in .\anaconda\lib\site-packages (from node) (1.7)
Requirement already satisfied: optional-django==0.1.0 in .\anaconda\lib\site-packages (from npm) (0.1.0)
Requirement already satisfied: zope.event in .\anaconda\lib\site-packages (from zope.component->node) (4.5.0)
Requirement already satisfied: zope.interface>=5.3.0a1 in .\anaconda\lib\site-packages (from zope.component->node) (5.3.0)
Requirement already satisfied: zope.hookable>=4.2.0 in .\anaconda\lib\site-packages (from zope.component->node) (5.1.0)
Requirement already satisfied: zope.proxy in .\anaconda\lib\site-packages (from zope.deferredimport->node) (4.5.0)

e:\lxs>pyright
pyright
 * Environment already exists: C:\Users\ADMINI~1\AppData\Local\Temp\pyright-python.Administrator\env
Traceback (most recent call last):
  File "e:\lxs\anaconda\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "e:\lxs\anaconda\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "e:\lxs\anaconda\Scripts\pyright.exe\__main__.py", line 7, in <module>
  File "e:\lxs\anaconda\lib\site-packages\pyright\cli.py", line 72, in entrypoint
    sys.exit(main(sys.argv[1:]))
  File "e:\lxs\anaconda\lib\site-packages\pyright\cli.py", line 20, in main
    return run(*args, **kwargs).returncode
  File "e:\lxs\anaconda\lib\site-packages\pyright\cli.py", line 36, in run
    npx = node.version('npx')
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 116, in version
    proc = run(target, '--version', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 86, in run
    binary = _ensure_available(target)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 34, in _ensure_available
    return Binary(path=_ensure_node_env(target), strategy=Strategy.NODEENV)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 52, in _ensure_node_env
    _install_node_env()
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 79, in _install_node_env
    subprocess.run(args, check=True)
  File "e:\lxs\anaconda\lib\subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['e:\\lxs\\anaconda\\python.exe', '-m', 'nodeenv', 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pyright-python.Administrator\\env']' returned non-zero exit status 2.

e:\lxs>pip install pyright python-lsp-server
pip install pyright python-lsp-server
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: pyright in .\anaconda\lib\site-packages (1.1.248)
Requirement already satisfied: python-lsp-server in .\anaconda\lib\site-packages (1.4.1)
Requirement already satisfied: nodeenv>=1.6.0 in .\anaconda\lib\site-packages (from pyright) (1.6.0)
Requirement already satisfied: python-lsp-jsonrpc>=1.0.0 in .\anaconda\lib\site-packages (from python-lsp-server) (1.0.0)
Requirement already satisfied: pluggy>=1.0.0 in .\anaconda\lib\site-packages (from python-lsp-server) (1.0.0)
Requirement already satisfied: ujson>=3.0.0 in .\anaconda\lib\site-packages (from python-lsp-server) (4.0.2)
Requirement already satisfied: setuptools>=39.0.0 in .\anaconda\lib\site-packages (from python-lsp-server) (52.0.0.post20210125)
Requirement already satisfied: jedi<0.19.0,>=0.17.2 in .\anaconda\lib\site-packages (from python-lsp-server) (0.17.2)
Requirement already satisfied: parso<0.8.0,>=0.7.0 in .\anaconda\lib\site-packages (from jedi<0.19.0,>=0.17.2->python-lsp-server) (0.7.1)

e:\lxs>

另外,我现在更新成Emacs28.1了,Spacemacs也通过gitee更新到新版,每次启动Spacemacs首页的Recent Files前面为什么显示异常字符?其中init.el中对于lsp-bridge主要添加了如下配置:

(defun dotspacemacs/user-config ()
  "Configuration for user code:
This function is called at the very end of Spacemacs startup, after layer
configuration.
Put your configuration code here, except for variables that should be set
before packages are loaded."

  (when (display-graphic-p)
    (require 'all-the-icons))
  ;; ;; or
  ;; (use-package all-the-icons
  ;;   :if (display-graphic-p))

  (add-to-list 'load-path "e:/lxs/.emacs.d/lisp/")
  (add-to-list 'load-path "e:/lxs/.emacs.d/lisp/lsp-bridge/")
  (add-to-list 'load-path "e:/lxs/.emacs.d/lisp/lsp-bridge/completion/")
  (add-to-list 'load-path "e:/lxs/.emacs.d/lisp/lsp-bridge/core/")

  (require 'lsp-bridge)             ;; load lsp-bridge
  (global-corfu-mode)               ;; use corfu as completion ui
  (require 'lsp-bridge-orderless)   ;; make lsp-bridge support fuzzy match, optional
  (require 'lsp-bridge-icon)        ;; show icon for completion items, optional
  (global-lsp-bridge-mode)

  (when (display-graphic-p)
    (require 'all-the-icons))

  (use-package corfu
    ;; Optional customizations
    ;; :custom
    ;; (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
    ;; (corfu-auto t)                 ;; Enable auto completion
    ;; (corfu-separator ?\s)          ;; Orderless field separator
    ;; (corfu-quit-at-boundary nil)   ;; Never quit at completion boundary
    ;; (corfu-quit-no-match nil)      ;; Never quit, even if there is no match
    ;; (corfu-preview-current nil)    ;; Disable current candidate preview
    ;; (corfu-preselect-first nil)    ;; Disable candidate preselection
    ;; (corfu-on-exact-match nil)     ;; Configure handling of exact matches
    ;; (corfu-echo-documentation nil) ;; Disable documentation in the echo area
    ;; (corfu-scroll-margin 5)        ;; Use scroll margin

    ;; Enable Corfu only for certain modes.
    ;; :hook ((prog-mode . corfu-mode)
    ;;        (shell-mode . corfu-mode)
    ;;        (eshell-mode . corfu-mode))

    ;; Recommended: Enable Corfu globally.
    ;; This is recommended since Dabbrev can be used globally (M-/).
    ;; See also `corfu-excluded-modes'.
    :init
    (global-corfu-mode))

  ;; A few more useful configurations...
  (use-package emacs
    :init
    ;; TAB cycle if there are only few candidates
    (setq completion-cycle-threshold 3)

    ;; Emacs 28: Hide commands in M-x which do not apply to the current mode.
    ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
    ;; (setq read-extended-command-predicate
    ;;       #'command-completion-default-include-p)

    ;; Enable indentation+completion using the TAB key.
    ;; `completion-at-point' is often bound to M-TAB.
    (setq tab-always-indent 'complete))

  (require 'package)
  (add-to-list 'package-archives
               '("melpa-stable" . "https://stable.melpa.org/packages/"))
  (package-initialize)

  (use-package markdown-mode
    :ensure t
    :mode ("README\\.md\\'" . gfm-mode)
    :init (setq markdown-command "multimarkdown"))

  (use-package orderless
    :ensure t
    :custom
    (completion-styles '(orderless basic))
    (completion-category-overrides '((file (styles basic partial-completion)))))
  (require 'orderless)
  (setq completion-styles '(orderless basic)
        completion-category-overrides '((file (styles basic partial-completion))))

  (require 'posframe)

  ;; (when (posframe-workable-p)
  ;;   (posframe-show " *my-posframe-buffer*"
  ;;                  :string "This is a test"
  ;;                  :position (point)))


pyright.json 那个文件里面 command 里面改成 pylsp 就可以了。

我将e:/lxs/.emacs.d/lisp/lsp-bridge/langserver/pyright_windows.json和e:/lxs/.emacs.d/lisp/lsp-bridge/langserver/pyright.json 里的pyright都改成了pylsp,为什么打开Python文件还是启动pyright并失败?

先试一下:

  • 升级 Python 到 3.7 以上
  • 更新已经安装的 pip 包

如果还不行,就看命令行的错误信息,找到出错文件和行,看看那一行到底写了什么。

1 个赞

我在两台电脑安装pyright都提示正常安装了,但貌似都没法运行,您知道什么原因吗? 之前用的是ThinkPad X280 Windows10 64位,一直没成功。 现在又试了ThinkPad X230 Windows7 32位,报错还是类似的:

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

e:\lxs>pip install pyright node npm
pip install pyright node npm
WARNING: Ignoring invalid distribution -ip (e:\lxs\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (e:\lxs\anaconda\lib\site-packages)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: pyright in .\anaconda\lib\site-packages (1.1.251)
Requirement already satisfied: node in .\anaconda\lib\site-packages (1.0)
Requirement already satisfied: npm in .\anaconda\lib\site-packages (0.1.1)
Requirement already satisfied: nodeenv>=1.6.0 in .\anaconda\lib\site-packages (from pyright) (1.6.0)
Requirement already satisfied: zope.deferredimport in .\anaconda\lib\site-packages (from node) (4.4)
Requirement already satisfied: zope.lifecycleevent in .\anaconda\lib\site-packages (from node) (4.4)
Requirement already satisfied: zope.deprecation in .\anaconda\lib\site-packages (from node) (4.4.0)
Requirement already satisfied: odict>=1.8.0 in .\anaconda\lib\site-packages (from node) (1.9.0)
Requirement already satisfied: setuptools in .\anaconda\lib\site-packages (from node) (58.3.0)
Requirement already satisfied: plumber>=1.5 in .\anaconda\lib\site-packages (from node) (1.7)
Requirement already satisfied: zope.component in .\anaconda\lib\site-packages (from node) (5.0.1)
Requirement already satisfied: optional-django==0.1.0 in .\anaconda\lib\site-packages (from npm) (0.1.0)
Requirement already satisfied: zope.hookable>=4.2.0 in .\anaconda\lib\site-packages (from zope.component->node) (5.1.0)
Requirement already satisfied: zope.event in .\anaconda\lib\site-packages (from zope.component->node) (4.5.0)
Requirement already satisfied: zope.interface>=5.3.0a1 in .\anaconda\lib\site-packages (from zope.component->node) (5.3.0)
Requirement already satisfied: zope.proxy in .\anaconda\lib\site-packages (from zope.deferredimport->node) (4.5.0)
WARNING: Ignoring invalid distribution -ip (e:\lxs\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (e:\lxs\anaconda\lib\site-packages)

e:\lxs>python -V
python -V
Python 3.8.8

e:\lxs>pip -V
pip -V
pip 21.3.1 from e:\lxs\anaconda\lib\site-packages\pip (python 3.8)

e:\lxs>pyright 
pyright 
 * Environment already exists: C:\Users\cailiya\AppData\Local\Temp\pyright-python.snpri\env
Traceback (most recent call last):
  File "e:\lxs\anaconda\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "e:\lxs\anaconda\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "e:\lxs\anaconda\Scripts\pyright.exe\__main__.py", line 7, in <module>
  File "e:\lxs\anaconda\lib\site-packages\pyright\cli.py", line 72, in entrypoint
    sys.exit(main(sys.argv[1:]))
  File "e:\lxs\anaconda\lib\site-packages\pyright\cli.py", line 20, in main
    return run(*args, **kwargs).returncode
  File "e:\lxs\anaconda\lib\site-packages\pyright\cli.py", line 36, in run
    npx = node.version('npx')
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 116, in version
    proc = run(target, '--version', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 86, in run
    binary = _ensure_available(target)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 34, in _ensure_available
    return Binary(path=_ensure_node_env(target), strategy=Strategy.NODEENV)
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 52, in _ensure_node_env
    _install_node_env()
  File "e:\lxs\anaconda\lib\site-packages\pyright\node.py", line 79, in _install_node_env
    subprocess.run(args, check=True)
  File "e:\lxs\anaconda\lib\subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['e:\\lxs\\anaconda\\python.exe', '-m', 'nodeenv', 'C:\\Users\\cailiya\\AppData\\Local\\Temp\\pyright-python.snpri\\env']' returned non-zero exit status 2.

e:\lxs>

看下是不是跟你同样的问题:

1 个赞

非常感谢大佬,看对方应该就是和我同样的问题:

 $ pip install pyright
Looking in indexes: https://pypi.org/simple, https://masma:****@pkgs.dev.azure.com/dongenergy-p/_packaging/MarketTrading%40Local/pypi/simple/, https://masma:****@pkgs.dev.azure.com/dongenergy-p/_packaging/analytics-workspace/pypi/simple/
Collecting pyright
  Downloading pyright-1.1.238-py3-none-any.whl (15 kB)
Collecting nodeenv>=1.6.0
  Using cached nodeenv-1.6.0-py2.py3-none-any.whl (21 kB)
Installing collected packages: nodeenv, pyright
Successfully installed nodeenv-1.6.0 pyright-1.1.238
WARNING: You are using pip version 20.2.3; however, version 22.0.4 is available.
You should consider upgrading via the 'c:\repos\private\now\.venv\scripts\python.exe -m pip install --upgrade pip' command.     
(.venv) 
MASMA@PC81978 MINGW64 /c/repos/private/now
$ pyright --verifytypes panel
 * Environment already exists: C:\Users\masma\AppData\Local\Temp\pyright-python.MASMA\env
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\repos\private\now\.venv\Scripts\pyright.exe\__main__.py", line 7, in <module>
  File "c:\repos\private\now\.venv\lib\site-packages\pyright\cli.py", line 72, in entrypoint
    sys.exit(main(sys.argv[1:]))
  File "c:\repos\private\now\.venv\lib\site-packages\pyright\cli.py", line 20, in main
    return run(*args, **kwargs).returncode
  File "c:\repos\private\now\.venv\lib\site-packages\pyright\cli.py", line 36, in run
    npx = node.version('npx')
  File "c:\repos\private\now\.venv\lib\site-packages\pyright\node.py", line 116, in version
    proc = run(target, '--version', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "c:\repos\private\now\.venv\lib\site-packages\pyright\node.py", line 86, in run
    binary = _ensure_available(target)
  File "c:\repos\private\now\.venv\lib\site-packages\pyright\node.py", line 34, in _ensure_available
    return Binary(path=_ensure_node_env(target), strategy=Strategy.NODEENV)
  File "c:\repos\private\now\.venv\lib\site-packages\pyright\node.py", line 52, in _ensure_node_env
    _install_node_env()
  File "c:\repos\private\now\.venv\lib\site-packages\pyright\node.py", line 79, in _install_node_env
    subprocess.run(args, check=True)
  File "C:\Program Files\Python39\lib\subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['c:\\repos\\private\\now\\.venv\\scripts\\python.exe', '-m', 'nodeenv', 'C:\\Users\\masma\\AppData\\Local\\Temp\\pyright-python.MASMA\\env']' returned non-zero exit status 2.

奈何本人太菜,还是不太明白应该怎么解决。

If I add nodejs to my PATH, I can run pyright.

这是将nodejs加入Windows环境变量的PATH吧?

请问应该添加哪个目录?e:\lxs.emacs.d\elpa\27.2\develop\nodejs-repl-20200802.1310\吗?

Yes, pyright does require node to be installed.

If you ran pip install pyright, then you are using a community-maintained package to install pyright through pip. If you are running into problems using this installation method or have suggestions for improved error messages, please file a bug with that project.

请问这又是什么意思?需要将node卸载吗?用pip方式安装的是不稳定的社区开发版吗?从哪找具体问题?或者怎么安装稳定的pyright版本?

再次感谢大佬多次耐心的答疑~

可能不止加 PATH 那么简单,社区版在 Windows 上应该还有问题待解决:

我没有 Windows,无法验证。

1 个赞

我电脑里node相关的exe文件只找到"E:\lxs\anaconda\Scripts\nodeenv.exe",早就已经在我的PATH里。


e:\lxs>echo %PATH%
echo %PATH%
e:\lxs\anaconda;e:\lxs\anaconda\Library\bin;e:\lxs\anaconda\Scripts;c:\PROGRAM FILES\INTEL\ICLS CLIENT;%SYSTEMROOT%\SYSTEM32;%SYSTEMROOT%;%SYSTEMROOT%\SYSTEM32\WBEM;%SYSTEMROOT%\SYSTEM32\WINDOWSPOWERSHELL\V1.0;c:\PROGRAM FILES\INTEL\INTEL(R) MANAGEMENT ENGINE COMPONENTS\DAL;c:\PROGRAM FILES\INTEL\INTEL(R) MANAGEMENT ENGINE COMPONENTS\IPT;d:\Program Files\Gow\bin;e:\lxs\Git\cmd;c:\Windows\SYSTEM32;c:\Windows;c:\Windows\SYSTEM32\WBEM;c:\Windows\SYSTEM32\WINDOWSPOWERSHELL\V1.0;e:\lxs\i686\libexec\emacs\27.2\i686-w64-mingw32

e:\lxs>node 
node 
'node' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

e:\lxs>nodejs
nodejs
'nodejs' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

e:\lxs>ls e:/lxs/anaconda/Scripts/node*
ls e:/lxs/anaconda/Scripts/node*
e:/lxs/anaconda/Scripts/nodeenv.exe

e:\lxs>

谢谢大佬,看来的确问题比较复杂,我看pyright官网 pyright · PyPI安装方式就是pip install pyright,我通过这种方式安装的版本1.1.251也和官网显示的最新版一致,我实际安装的是社区版的pyright吗?

有没有什么办法安装在Windows下更适用的pyright稳定版?


e:\lxs\.spacemacs.d>pip install pyright
pip install pyright
WARNING: Ignoring invalid distribution -ip (e:\lxs\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (e:\lxs\anaconda\lib\site-packages)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: pyright in e:\lxs\anaconda\lib\site-packages (1.1.251)
Requirement already satisfied: nodeenv>=1.6.0 in e:\lxs\anaconda\lib\site-packages (from pyright) (1.6.0)
WARNING: Ignoring invalid distribution -ip (e:\lxs\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (e:\lxs\anaconda\lib\site-packages)

我这边目前可行的办法

  • 安装nodejs
  • 通过npm安装pyright (全局安装 npm -g)
  • pyright.json,写pyright-server.com的全路径