Skip to content
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

Ensure default global interpreter used is the default python in terminal #19818

Open
2 tasks
karrtikr opened this issue Sep 12, 2022 · 8 comments
Open
2 tasks
Labels
area-environments Features relating to handling interpreter environments debt Covers everything internal: CI, testing, refactoring of the codebase, etc. feature-request Request for new features or functionality needs PR Ready to be worked on partner ask

Comments

@karrtikr
Copy link

karrtikr commented Sep 12, 2022

  • Currently in case of global interpreters, the interpreter with the highest version is preferred:

    image
    We should instead prefer the interpreter/environment which appears first in PATH, new selection order can be:

    • Look for python in PATH: python -c"import sys;print(sys.executable)"
    • If none of these exist, then it look for python interpreter with the highest version.
  • Publish the auto-selection order in our docs.

cc/ @karthiknadig

@karrtikr karrtikr added feature-request Request for new features or functionality area-environments Features relating to handling interpreter environments needs PR Ready to be worked on labels Sep 12, 2022
@karrtikr karrtikr self-assigned this Sep 12, 2022
@karrtikr karrtikr changed the title Ensure auto-selected interpreter is referred using python in terminal Ensure default interpreter auto-selected by extension can be referred using python in terminal Sep 12, 2022
@karthiknadig
Copy link
Member

@karrtikr This should use an internal symlink that is always on PATH. That symlink should point to the selected python in a given workspace. That way python in terminal will always be python that is selected in the extension. This is easier said than done.

@karrtikr
Copy link
Author

This is easier said than done.

Which is why I think for now we should simply select the default python in terminal instead of selecting the highest version.

@karthiknadig
Copy link
Member

Which is why I think for now we should simply select the default python in terminal instead of selecting the highest version.

I am not sure it helps. I think it will confuse even more, because outside of VS Code when users type python in the terminal it will be a different experience. If we go with ensuring python always points to selected python, then there are clear rules, in VS Code terminal the python is the selected python, outside it will be whatever the terminal decides.

If, we go by the above plan, there are no clear rules. In, activated scenario the VS Code terminal is the selected python. But in global scenario it is not. And the global scenario, does not reflect what would happen in a terminal outside of VS Code. It is harder to define what happens.

@karrtikr
Copy link
Author

I understand that's the ideal solution, but I'm just talking about improving the default experience.

But in global scenario it is not.

By default it will be, unless user explicitly changes the global interpreter. It's better than what we currently have now, where we select the highest version.

@luabud
Copy link
Member

luabud commented Sep 8, 2023

maybe related? #13327

@karrtikr
Copy link
Author

@luabud Yep, #13327 would be nice (and can be done btw with the terminal exp), but I think we should still change the auto-selection order to select default python configured in the system.

For eg. most codespaces, or dev containers are configured to use Python on PATH by default, it can have the right dependencies already installed.

@karrtikr karrtikr removed their assignment Oct 26, 2023
@karrtikr karrtikr changed the title Ensure default interpreter auto-selected by extension can be referred using python in terminal Ensure default global interpreter auto-selected by extension is the default python in terminal Oct 27, 2023
@karrtikr karrtikr changed the title Ensure default global interpreter auto-selected by extension is the default python in terminal Ensure default global interpreter used is the default python in terminal Oct 27, 2023
@pfmoore
Copy link

pfmoore commented Oct 30, 2023

For eg. most codespaces, or dev containers are configured to use Python on PATH by default, it can have the right dependencies already installed.

Codespaces and dev containers are not the typical user setup. The py launcher is the standard (PEP 397) means of accessing Python on Windows, and not supporting it would make the user experience for people using the python.org distributions of Python more difficult (i.e., need customisation to work as expected).

@karrtikr
Copy link
Author

FWIW extension can be configured to use the py launcher by default by adding the following to User settings:

"python.defaultInterpreterPath": "py"

and then syncing settings across all devices. Only a one time customisation is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-environments Features relating to handling interpreter environments debt Covers everything internal: CI, testing, refactoring of the codebase, etc. feature-request Request for new features or functionality needs PR Ready to be worked on partner ask
Projects
None yet
Development

No branches or pull requests

4 participants