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

python: hide unsupported Python versions from interpreter dropdown #3740

Closed
Vinnish-A opened this issue Jun 29, 2024 · 12 comments
Closed

python: hide unsupported Python versions from interpreter dropdown #3740

Vinnish-A opened this issue Jun 29, 2024 · 12 comments
Assignees
Labels

Comments

@Vinnish-A
Copy link

Dear developers and maintainers, I have the highest respect for your outstanding work.

When I ran a test on python version 3.6.2 with jupyter, I was told that I needed to upgrade ipykernel to connect to the console. Positron reminds me that I need to upgrade ipykernel, but doesn't report the minimum version required, and the automatic installation that the ide tried afterwards undoubtedly failed, after all, 3.6 is indeed a bit outdated.

Nonetheless, I think the minimum version required to report that allows users to install themselves in the terminal is needed.

Thank you for your attention and have a great day!

@jthomasmock
Copy link
Contributor

Thanks for the kind words and interest @Vinnish-A !

We currently support Python 3.8 to 3.12 as seen in the Wiki: https://github.com/posit-dev/positron/wiki#python-prerequisites -- that may be the specific issue you are facing right now.

@seeM
Copy link
Contributor

seeM commented Jun 30, 2024

Thank you for the kind words and for the feedback!

As Tom mentioned, we only support Python >= 3.8. If you were able to select a Python 3.6 interpreter, that is actually a bug! Could you please share more about your Python 3.6 environment? How was it installed (homebrew, conda, etc), and was it a virtual environment?

We could also include the minimum IPyKernel version in the prompt to install/upgrade it.

@Vinnish-A
Copy link
Author

Of course, I am very willing to report to you the specific situation during the use process.

First of all, it's very strange that yesterday I could still automatically find and select the Python 3.6.2 interpreter installed in a conda environment through the button in the top right corner of Positron. However, when I tried to reproduce this issue today, Python 3.6.2 no longer appears in the options for automatic search.

Although I can currently find it by setting the Python 3.6.2 as the default interpreter in settings, due to the lack of a suitable IPyKernel, Python will fail to start, which means it cannot be used. This is strange because I am sure that yesterday I did run a program in an ipynb file using this Python 3.6.2 , as I only configured Keras in this version of Python.

But no matter what, this problem seems like it shouldn't have occurred, but now it's gone, hopefully we can encounter it again in the future.

@seeM
Copy link
Contributor

seeM commented Jul 1, 2024

Glad it's sorted for now. Is it possible that you had set Python 3.6.2 as the default interpreter in settings the first time too, and that caused it to show in the select interpreter menu?

@juliasilge
Copy link
Contributor

Let's double check that:

  • less than Python 3.8 is not usable
  • we check the version of ipykernel and give good feedback to the user for too-old versions

@juliasilge juliasilge added this to the Future milestone Jul 5, 2024
@petetronic
Copy link
Collaborator

petetronic commented Jul 5, 2024

On the first point, I installed Python 3.6.15 using pyenv and Positron did show it as an interpreter and tried to offer to install ipykernel. It eventually fails:
Python 3.6.15 (Pyenv) exited unexpectedly with error: SyntaxError: future feature annotations is not defined.
The minimum supported version is 3.8, so it should not be presented in the interpreter list.

On the second point of errors not explaining what version of ipykernel is needed... while we do try to install a later ipykernel if the version is <= 6.19.1, it seems that if another valid Python interpreter is currently running, and you try to switch to an interpreter with a missing or invalid (too early, < 6.19.1) version of ipykernel, it fails and leaves an error on the console, e.g.

Could not start runtime: failed to install ipykernel for Python 3.10.8 64-bit ('3.10.8').

It should attempt to stop the old interpreter, successfully install ipykernel when prompted, and start the new interpreter.

@petetronic petetronic modified the milestones: Future, Release Candidate Jul 5, 2024
@petetronic petetronic added support bug Something isn't working regression labels Jul 7, 2024
@isabelizimm
Copy link
Contributor

I just tried to reproduce the failure cases mentioned:

... it seems that if another valid Python interpreter is currently running, and you try to switch to an interpreter with a missing or invalid (too early, < 6.19.1) version of ipykernel, it fails and leaves an error on the console, ... It should attempt to stop the old interpreter, successfully install ipykernel when prompted, and start the new interpreter.
and the interpreter now acts as expected, upgrading ipykernel if needed before starting the console

No longer occurs. If an incorrect ipykernel is installed, users are prompted to upgrade and the console launches as expected.

The minimum supported version is 3.8, so it should not be presented in the interpreter list.

Is still happening, and needs to be fixed.

Going to rename this issue so the goals are more clear here!

@isabelizimm isabelizimm changed the title Specify the specific version required for ipykernel python: hide unsupported Python versions from interpreter dropdown Feb 13, 2025
@isabelizimm isabelizimm self-assigned this Feb 13, 2025
isabelizimm added a commit that referenced this issue Feb 21, 2025
### Release Notes

<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
  The note will automatically be tagged with the language.

These notes are typically filled by the Positron team. If you are an
external
  contributor, you may ignore this section.
-->

#### New Features

- N/A

#### Bug Fixes

- #3740 filters out unsupported (<3.8) Python versions from the `Python:
Select Interpreter` dropdown


### QA Notes

1. create a Python interpreter <3.8 (if you are a pyenv user, you can do
`pyenv install 3.6`)
2. go to `Python: Select Interpreter`
3. should not appear in dropdown
sharon-wang added a commit that referenced this issue Feb 24, 2025
…ettings (#6398)

### Summary
- addresses #3574 for both the JS and native locators
- also implements #6254 for the JS locator (previously [only implemented
for the native
locator](#6261))
- introduces new settings
- `python.interpreters.include`: List of folders to search for Python
installations. These folders are searched in addition to the default
folders for your operating system.
- `python.interpreters.exclude`: List of interpreter paths or folders to
exclude from the available Python installations. These interpreters will
not be displayed in the Positron UI. This option takes precedence over
the `include` option.
- adds new command available via Command Palette:
`python.interpreters.debugInfo`: "Print interpreter debug information to
Output"
- Opens the Python Language Pack Output and prints python interpreter
settings info as well as info about each discovered python runtime

#### Settings UI

<img width="1020" alt="image"
src="https://github.com/user-attachments/assets/137d7798-50c8-4668-9444-db9917e91417"
/>

#### Settings JSON

```json
    "python.interpreters.include": [
        "~/scratch"
    ],
    "python.interpreters.exclude": [
        "/usr/bin/python3",
        "/opt/homebrew",
        "/usr/local/bin",
        "/opt/python",
        "~/scratch"
    ]
```

#### Python Language Pack Output
Some log prefixes/messages to search for:
- `pythonRuntimeDiscoverer`: to find out if any runtimes were filtered
out during discovery
- `shouldIncludeInterpreter`: whether or not the interpreter will be
included based on the user settings
- `Not registering runtime ${extraData.pythonPath} as it is excluded via
user settings.`: if the runtime is not getting registered because the
user excluded it
- `getAdditionalEnvDirs`: native python finder -- list all the
additional directories being searched, such as the user-included dirs

<details><summary>Sample Output from `python.interpreters.debugInfo`:
"Print interpreter debug information to Output"</summary>

```js
2025-02-24 10:43:17.026 [info] =====================================================================
2025-02-24 10:43:17.026 [info] =============== [START] PYTHON INTERPRETER DEBUG INFO ===============
2025-02-24 10:43:17.026 [info] =====================================================================
2025-02-24 10:43:17.026 [info] Python interpreter settings: {
  defaultInterpreterPath: '/Users/hello/qa-example-content/.venv/bin/python',
  'interpreters.include': [ '/Users/hello/scratch' ],
  'interpreters.exclude': [
    '/usr/bin/python3',
    '/opt/homebrew',
    '/usr/local/bin',
    '/opt/python',
    '/Users/hello/scratch'
  ]
}
2025-02-24 10:43:17.026 [info] Python interpreters discovered: [
  {
    name: 'Python 3.13.1 64-bit',
    path: '/opt/homebrew/bin/python3',
    versionInfo: { version: '3.13.1', supportedVersion: true },
    envInfo: { envType: 'Global', envName: '' },
    enablementInfo: {
      visibleInUI: false,
      includedInSettings: false,
      excludedInSettings: true
    }
  },
  {
    name: 'Python 3.10.4 64-bit',
    path: '/opt/python/3.10.4/bin/python',
    versionInfo: { version: '3.10.4', supportedVersion: true },
    envInfo: { envType: 'Unknown', envName: '' },
    enablementInfo: {
      visibleInUI: false,
      includedInSettings: false,
      excludedInSettings: true
    }
  },
  {
    name: "Python 3.12.2 64-bit ('3.12.2': pyenv)",
    path: '/Users/hello/.pyenv/versions/3.12.2/bin/python',
    versionInfo: { version: '3.12.2', supportedVersion: true },
    envInfo: { envType: 'Pyenv', envName: '3.12.2' },
    enablementInfo: {
      visibleInUI: true,
      includedInSettings: false,
      excludedInSettings: false
    }
  },
  {
    name: "Python 3.6.15 64-bit ('3.6.15': pyenv)",
    path: '/Users/hello/.pyenv/versions/3.6.15/bin/python',
    versionInfo: { version: '3.6.15', supportedVersion: false },
    envInfo: { envType: 'Pyenv', envName: '3.6.15' },
    enablementInfo: {
      visibleInUI: true,
      includedInSettings: false,
      excludedInSettings: false
    }
  },
  {
    name: "Python 3.10.4 ('.venv': venv)",
    path: '/Users/hello/qa-example-content/.venv/bin/python',
    versionInfo: { version: '3.10.4', supportedVersion: true },
    envInfo: { envType: 'Venv', envName: '.venv' },
    enablementInfo: {
      visibleInUI: true,
      includedInSettings: false,
      excludedInSettings: false
    }
  },
  {
    name: 'Python 3.10.4 64-bit (custom)',
    path: '/Users/hello/scratch/3.10.4/bin/python',
    versionInfo: { version: '3.10.4', supportedVersion: true },
    envInfo: { envType: 'Unknown', envName: '' },
    enablementInfo: {
      visibleInUI: false,
      includedInSettings: true,
      excludedInSettings: true
    }
  },
  {
    name: 'Python 3.9.6 64-bit',
    path: '/usr/bin/python3',
    versionInfo: { version: '3.9.6', supportedVersion: true },
    envInfo: { envType: 'Global', envName: '' },
    enablementInfo: {
      visibleInUI: false,
      includedInSettings: false,
      excludedInSettings: true
    }
  },
  {
    name: 'Python 3.10.4 64-bit',
    path: '/usr/local/bin/python3',
    versionInfo: { version: '3.10.4', supportedVersion: true },
    envInfo: { envType: 'Global', envName: '' },
    enablementInfo: {
      visibleInUI: false,
      includedInSettings: false,
      excludedInSettings: true
    }
  },
  {
    name: 'Python 3.11.6 64-bit',
    path: '/usr/local/bin/python3.11',
    versionInfo: { version: '3.11.6', supportedVersion: true },
    envInfo: { envType: 'Global', envName: '' },
    enablementInfo: {
      visibleInUI: false,
      includedInSettings: false,
      excludedInSettings: true
    }
  }
]
2025-02-24 10:43:17.026 [info] =====================================================================
2025-02-24 10:43:17.026 [info] ================ [END] PYTHON INTERPRETER DEBUG INFO ================
2025-02-24 10:43:17.026 [info] =====================================================================


```

</details> 


### Release Notes

#### New Features

- New settings to include additional Python interpreter search
directories or exclude Python interpreters from the UI (#3574)

#### Bug Fixes

- filters out unsupported (<3.8) Python versions from the `Python:
Select Interpreter` dropdown (#3740) @isabelizimm

### QA Notes

- Please verify these options using both the JS and Native locators.
Toggle between the locators by updating setting `python.locator`.
- Positron will need to be restarted upon changing the
`python.interpreters.include`/`python.interpreters.exclude` settings so
that discovery can re-run with the settings applied
- If an interpreter path is captured in both options, it will be
excluded
- If a user has a python install they want to include at path
`/1/2/3/4/5/3.10.4/bin/python`, they should use `/1/2/3/4/5` or
`/1/2/3/4/5/3.10.4` as the included directory.
- Windows users can specify paths with either path separator
- Relative paths specified in the options are ignored
- If a user starts an interpreter, then excludes or un-includes it and
restarts Positron, it will still be selected upon restart
    - if they shut it down and then restart, it should no longer show

---------

Co-authored-by: Isabel Zimmerman <[email protected]>
@testlabauto
Copy link
Contributor

Unfortunately, I am seeing

Image

@isabelizimm
Copy link
Contributor

Oh no! 😞

Here is code that should be filtering out <3.8 in the Positron interpreter dropdown. It does seem to be filtering if you step through this code/look at logs, so it must be repopulating somewhere else.

Unsupported versions are successfully filtered in the Python: Select Interpreter workflow

@seeM
Copy link
Contributor

seeM commented Feb 27, 2025

@isabelizimm We also register runtimes when certain interpreter-related events fire. We might not be filtering there.

@sharon-wang
Copy link
Member

@isabelizimm We also register runtimes when certain interpreter-related events fire. We might not be filtering there.

ah yes I encountered this when working on the includes/excludes here:

/**
* Registers a new language runtime with Positron.
*
* @param runtimeMetadata The metadata for the runtime to register.
*/
public registerLanguageRuntime(runtime: positron.LanguageRuntimeMetadata): void {
const extraData = runtime.extraRuntimeData as PythonRuntimeExtraData;
// Check if the interpreter should be included in the list of registered runtimes
if (shouldIncludeInterpreter(extraData.pythonPath)) {
// Save the runtime for later use
this.registeredPythonRuntimes.set(extraData.pythonPath, runtime);
this.onDidDiscoverRuntimeEmitter.fire(runtime);
} else {
traceInfo(`Not registering runtime ${extraData.pythonPath} as it is excluded via user settings.`);
}
}

isabelizimm added a commit that referenced this issue Feb 28, 2025
Should block <3.8 interpreters from being registered when found. It
seems to fix everything for me locally, I think this is the only place
where old interpreters could sneak by.

### Release Notes

<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
  The note will automatically be tagged with the language.

These notes are typically filled by the Positron team. If you are an
external
  contributor, you may ignore this section.
-->

#### New Features

- N/A

#### Bug Fixes

- #3740 


### QA Notes

1. Create a Python interpreter <3.8 (if you are a pyenv user, you can do
pyenv install 3.6)
2. Fo to `Python: Select Interpreter`, should not appear in dropdown
3. Go to Positron interpreter selector, should not appear here either
melissa-barca pushed a commit that referenced this issue Feb 28, 2025
Should block <3.8 interpreters from being registered when found. It
seems to fix everything for me locally, I think this is the only place
where old interpreters could sneak by.

### Release Notes

<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
  The note will automatically be tagged with the language.

These notes are typically filled by the Positron team. If you are an
external
  contributor, you may ignore this section.
-->

#### New Features

- N/A

#### Bug Fixes

- #3740 


### QA Notes

1. Create a Python interpreter <3.8 (if you are a pyenv user, you can do
pyenv install 3.6)
2. Fo to `Python: Select Interpreter`, should not appear in dropdown
3. Go to Positron interpreter selector, should not appear here either
melissa-barca pushed a commit that referenced this issue Feb 28, 2025
Should block <3.8 interpreters from being registered when found. It
seems to fix everything for me locally, I think this is the only place
where old interpreters could sneak by.

### Release Notes

<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
  The note will automatically be tagged with the language.

These notes are typically filled by the Positron team. If you are an
external
  contributor, you may ignore this section.
-->

#### New Features

- N/A

#### Bug Fixes

- #3740 


### QA Notes

1. Create a Python interpreter <3.8 (if you are a pyenv user, you can do
pyenv install 3.6)
2. Fo to `Python: Select Interpreter`, should not appear in dropdown
3. Go to Positron interpreter selector, should not appear here either
melissa-barca pushed a commit that referenced this issue Feb 28, 2025
Should block <3.8 interpreters from being registered when found. It
seems to fix everything for me locally, I think this is the only place
where old interpreters could sneak by.

### Release Notes

<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
  The note will automatically be tagged with the language.

These notes are typically filled by the Positron team. If you are an
external
  contributor, you may ignore this section.
-->

#### New Features

- N/A

#### Bug Fixes

- #3740 


### QA Notes

1. Create a Python interpreter <3.8 (if you are a pyenv user, you can do
pyenv install 3.6)
2. Fo to `Python: Select Interpreter`, should not appear in dropdown
3. Go to Positron interpreter selector, should not appear here either
@testlabauto
Copy link
Contributor

Verified Fixed

Positron Version(s) : 2025.03.0-116 & 2025.04.0-20
OS Version          : OSX

Test scenario(s)

Did not see unsupported python in interpreter dropdown or command quick pick

Link(s) to TestRail test cases run or created:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants