-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pyright with venv still uses Python 2.7 on MacOS #2562
Comments
There should be additional details logged to the console. Can you provide those? Also, can you please post your config file? Pyright never activates a venv. It uses the directory of the venv that you specify. The only time that pyright invokes the python interpreter is when no venv is specified and it needs to fall back to the import resolution paths provided by the default python3 interpreter (i.e. the interpreter that runs when you type "python3" from the shell). |
Sure here's more detail:
|
OK, the import resolution search paths look correct. They point to your local venv, not to the libraries within the Python 2.7 interpreter on your machine. The part that's not correct is the pythonVersion. You haven't specified a pythonVersion in the config, and pyright is trying to determine which version you would like it to use for its analysis. I mentioned above that the only time pyright ever invokes the python interpreter is when no venv is specified and it needs to run the default interpreter to retrieve the import resolution paths. I forgot about one other case where the default python interpreter is invoked. If you don't specify a pythonVersion, pyright will invoke the default Python interpreter to try to query its version. It does not try to activate the configured virtual environment to get this information because virtual environment managers come in various flavors, and there are many ways to activate different venvs on different platforms. It simply does a shell invoke of @heejaechang, this is the code you wrote in fullAccessHost.ts, in the @jdtsmith, while we look for a solution, you can work around this issue by adding |
That works, thanks. The original issue I had combined this problem with an incorrectly specified venvPath, causing the old interpreter's path to be used, and picking up an old numpy install inside of v2.7. Which led to some real confusion as you might expect!
|
Oops. PR auto closed the issue. re-opened so that we can close it once fix is released. |
This is addressed in pyright 1.1.188, which I just published. |
Thanks. This does seem to fix the problem for straightforward calls to
|
The only way I can explain that is if emacs/lsp-mode is sending a "python.pythonPath" settings entry to pyright. If it does, pyright will execute the interpreter at the provided path rather than simply executing |
Yes, actually the plugin lsp-pyright is responsible. Too many chefs in the |
Describe the bug
The (unsupported) python2.7 interpreter bundled with MacOS is still chosen by pyright (despite the fixes in #829), but only when a venv is specified.
To Reproduce
Specify a "venvPath" and "venv" in config. Start `pyright --verbose" in that directory:
Expected behavior
pyright checks for python3 and finds it in the venv (even
python
in the venv points to python3).Additional context
It appears the fallback python3 -> python is disabled in the presence of a venv, and the venv is not first activated when determining the interpreter.
The text was updated successfully, but these errors were encountered: