Import resolution issue - pyright not using correct python #9489
synapticarbors
started this conversation in
General
Replies: 2 comments
-
|
Moving to a discussion topic since this is not a bug report but instead a configuration question. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
+1, one of my teammates got this same issue. The only (hacky) fix they found is deleting |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm running into an issue where pyright does not select the python environment defined by the
pythonexecutable that is found on the$PATH. My understanding from the docs is that ifpython.venvPathandpython.pythonPathare not set, then pyright should "use the default Python environment (i.e. the one that is invoked when typingpythonin the shell)."As an example, I have a python file called
foo.pythat contains:I activate python python environment using pixi (but the same is true with a conda env), such that:
and
if I then run:
It appears that the
python3that pyright is finding isfile:///Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9, which is incorrect, unless I'm not understanding the documentation correctly. If I pass in the python path explicitly I get the expected behavior:It almost looks like when pyright runs
python3to configure the environment for import resolution, it is happening in a subshell that didn't inherit the$PATH. To support this, in a terminal with no environments activated, runningpython3 -m sitegives back thesite-packagesthat pyright is finding.Has anyone seen this behavior before? I'm just running across this on a new machine. On my previous computer (running a much older version of MacOS) pyright behaved as expected. I've also tested older versions of pyright on this machine and they all behave the same way.
For completeness, this minimal example was run on the command line, but I spotted the issue initially in neovim when using Mason and nvim-lspconfig. Tests were on a machine running MacOS 15.1
Beta Was this translation helpful? Give feedback.
All reactions