# How to select python interpreter in Slicer on VSCode?

**URL:** <https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834>\
**Category:** Development\
**Tags:** macos\
**Created:** [June 5, 2023, 8:24am UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834 "2023-06-05T08:24:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![wrc](https://avatars.discourse-cdn.com/v4/letter/w/6de8d8/32.png) [@wrc](https://discourse.slicer.org/u/wrc)\
**Post date:** [June 5, 2023, 8:24am UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/1 "2023-06-05T08:24:42Z")

</div>

Hello, I failed to select python interpreter in Slicer on VSCode. The system is MacOS 13.4. I also tried other IDE but no success. However, I can run python script by python interpreter in Slicer from Terminal.

Here is the error information:

```auto
[error] [Error: Command failed: /Applications/Slicer.app/Contents/bin/PythonSlicer -I /Users/admin/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/get_output_via_markers.py /Users/admin/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/interpreterInfo.py
error: Application is NOT executable [/Applications/Slicer.app/Contents/bin/./python-real]
Usage
  PythonSlicer [options]

Options
  --launcher-help Display help
  --launcher-version Show launcher version information
  --launcher-verbose Verbose mode
  --launch Specify the application to launch
  --launcher-detach Launcher will NOT wait for the application to finish
  --launcher-no-splash Hide launcher splash
  --launcher-timeout Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
  --launcher-load-environment Specify the saved environment to load.
  --launcher-dump-environment Launcher will print environment variables to be set, then exit
  --launcher-show-set-environment-commands Launcher will print commands suitable for setting the parent environment (i.e. using 'eval' in a POSIX shell), then exit
  --launcher-additional-settings Additional settings file to consider
  --launcher-additional-settings-exclude-groups Comma separated list of settings groups that should NOT be overwritten by values in User and Additional settings. For example: General,Application,ExtraApplicationToLaunch
  --launcher-ignore-user-additional-settings Ignore additional user settings
  --launcher-generate-exec-wrapper-script Generate executable wrapper script allowing to set the environment
  --launcher-generate-template Generate an example of setting file

at ChildProcess.exithandler (node:child_process:409:12)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1112:16)
at ChildProcess._handle.onexit (node:internal/child_process:304:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: '/Applications/Slicer.app/Contents/bin/PythonSlicer -I /Users/admin/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/get_output_via_markers.py /Users/admin/.vscode/extensions/ms-python.python-2023.8.0/pythonFiles/interpreterInfo.py'
}

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 16, 2023, 4:38pm UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/2 "2023-06-16T16:38:24Z")

</div>

VSCode’s interpreter check failure is fixed in recent Slicer Preview Releases. Let us know how it works.

---

<div class="post-metadata">

**Author:** ![wrc](https://avatars.discourse-cdn.com/v4/letter/w/6de8d8/32.png) [@wrc](https://discourse.slicer.org/u/wrc)\
**Post date:** [August 22, 2023, 7:24am UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/3 "2023-08-22T07:24:18Z")

</div>

Unfortunately, it is not fixed in Slicer 5.4.0

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [August 22, 2023, 4:19pm UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/4 "2023-08-22T16:19:00Z")

</div>

For reference, this was tentatively fixed in this commit:

- [BUG: Fix launching .py files using Slicer with -I argument · Slicer/Slicer@0cf480d · GitHub](https://github.com/Slicer/Slicer/commit/0cf480de8721d685b5b97746032136e54501fc50)

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [August 22, 2023, 4:20pm UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/5 "2023-08-22T16:20:23Z")

</div>

@wrc To help us understand, was the fixed we integrated working and did it recently started to fail again?

---

<div class="post-metadata">

**Author:** ![wrc](https://avatars.discourse-cdn.com/v4/letter/w/6de8d8/32.png) [@wrc](https://discourse.slicer.org/u/wrc)\
**Post date:** [August 23, 2023, 2:14am UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/6 "2023-08-23T02:14:51Z")

</div>

In windows PC, it was fine. But in MacOS, it showed the same error in Slicer 5.4.0.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [August 23, 2023, 2:24am UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/7 "2023-08-23T02:24:10Z")

</div>

Thanks for the follow up.

If I understand your comment, the fix originally integrated fixed the issue on Windows but never fixed it on macOS ?

We are trying to understand if this is a recent regression or not. So any additional details would be helpful.

After the fix integrated by @lassoan and linked above, did it ever work on macOS using the Preview build ?

Could you include screenshot and step by step to illustrate how you configure the interpreter in VS Code ?

---

<div class="post-metadata">

**Author:** ![wrc](https://avatars.discourse-cdn.com/v4/letter/w/6de8d8/32.png) [@wrc](https://discourse.slicer.org/u/wrc)\
**Post date:** [August 23, 2023, 6:35am UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/8 "2023-08-23T06:35:19Z")

</div>

Sorry, I don’t know whether this problem has been solved before. I haven’t found the link to download the previous preview build (2023.5.18) so that I cannot test it. Here is the screenshot:  
click 3.9.6 64-bit

 ![1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/3/c333781f7793ffe10c04f6974619faaecc2ef85e.png)  
click enter interpreter path…  
 ![2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/a/6abb1bf0cd5f3839526639ceff1d7745ac3b1b64.png)  
input the path of PythonSlicer  
 ![3](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/7/578c6ad38337f6698760363bce61189d4ca7ca4a.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 23, 2023, 6:55am UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/9 "2023-08-23T06:55:42Z")

</div>

VS Code added a whole lot more operations to the interpreter check, which would require some more work to succeed. The “fix” in Slicer-5.4 should prevent Slicer instances to get started and get stuck with a popup, but not sufficient for VS Code current interpreter checks to complete successfully.

Getting a successful interpreter check would make a big difference when all the pyi files from VTK, ITK, Slicer, etc. are properly installed because we could then have auto-complete, documentation, etc. in the code editor. So, we should fix the interpreter check it when we have the pyi files in the Slicer installation package.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [August 23, 2023, 12:45pm UTC](https://discourse.slicer.org/t/how-to-select-python-interpreter-in-slicer-on-vscode/29834/10 "2023-08-23T12:45:20Z")

</div>

> when all the pyi files from VTK, ITK, Slicer, etc. are properly installed

For reference, this is tracked in the following issue:

> <https://github.com/Slicer/Slicer/issues/6690>
>
> \* \[\] https://github.com/Slicer/Slicer/issues/6686
> \* \[\] https://github.com/Sli…cer/Slicer/pull/6892
> \* \[\] https://github.com/Slicer/Slicer/issues/6688
> \* \[\] https://github.com/Slicer/Slicer/issues/6689
> \* \[\] https://github.com/Slicer/Slicer/issues/6875
> \* \[\] Add support for auto-completion of Qt-based classes
