Sublime Forum

LSP-pyright can't see my Pip packages

#1

Trying to use discord.py with Sublime.
Package list:

  • ayu & a file icon
  • LSP
  • LSP-file-watcher-chokidar
  • LSP-pyright
  • Package Control
  • Terminus

0 Likes

#2

Appears pyright is not possible to find python path.

If you rightlick onto the sidebar icon on the left corder of statusbar and open select “Output: LSP Log Panel”, does it display a proper path?

I have a folder “debug” opened and python installed at C:\Apps. The log panel prints the following and installed packages are resolved correctly.

LSP-pyright: Setting pythonPath for service "debug": "C:\Apps\python312\python.EXE"
LSP-pyright: stubPath c:\Data\debug\typings is not a valid directory.
LSP-pyright: Assuming Python version 3.12
LSP-pyright: Found 1 source file

In your case I’d expect a line such ase

LSP-pyright: Setting pythonPath for service "debug": "C:\users\...\local\programs\python\python311\python.EXE"

You can specify the python path manually via …

  1. Open Command Palette
  2. Type Preferences: LSP-pyright Settings
  3. adjust "python.pythonPath": "", setting
0 Likes

#3

Global packages seem working for me though… I would be astonished if pyright doens’t default it to python… or maybe we should.


Update: Test on a clean Win10 VM and it literally just works. So I have no clue what’s wrong on OP’s setup at this moment.

0 Likes

#4

Just to provide more information. https://github.com/sublimelsp/LSP-pyright/issues/277

OP ran import shutil; shutil.which('python') in ST console and got C:\Users\hughb\AppData\Local\Programs\Python\Python311\python.EXE. That standard Python user installation place on Windows.

0 Likes

#5

Whoops, it WAS using a different path for pyright. For anyone refering to this post, please go into ctrl+` and check the path is correct.

0 Likes