How to switch VS Code to use Pylance rather than Jedi?
Asked Answered
U

4

9

I am trying to use Structural Pattern Matching (PEP634) from Python 3.10, but Jedi language server doesn't support the syntax. I've heard Pylance is better, but I can't find any way to switch VS Code to Pylance.

I've downloaded the default Python extension, but only the Jedi language server is running.

How can I make the switch?


EDIT

Adding a picture of trying to search for "pylance" so there's no confusion, it's not there at all. It seems to claim it's part of the Python extension, but the language server being used is always Jedi.
enter image description here

Python extension packs: enter image description here

Ung answered 18/3, 2022 at 11:11 Comment(0)
U
9

I was using the open source version of VS Code which doesn't have all extensions. Switching to the proprietary version (available on the AUR) fixed my issue.

Ung answered 27/3, 2022 at 17:8 Comment(4)
Is pylance closed source or why does that happen? The aur package does look a bit hacky. Isnt there another way to get pylance on archlinux running?Indigence
If this doesn't work by itself, try additionally changing the python.languageServer setting to "Pylance" as suggested in other answers.Gradient
Using VSCodium. Didn't manage to get mine to work properly even after getting Pylance from Microsoft's extension marketplace.Supplementary
@MickeyDickeyoncodidact.com Pylance is proprietary and is thus only licensed to be used in official Microsoft products (that is, VSCode but not VSCodium). You can still use Pyright though.Dustidustie
F
7

Change the setting: python.languageServer

Footbridge answered 18/3, 2022 at 11:14 Comment(15)
I get the message "The Pylance Extension is not installed but the python.languageServer value is set to "Pylance"[...]". When I click "Download Pylance" vscode does nothing at all. If it's relevant, the python extension has the following uncaught exception: "Extension 'ms-python.python' CANNOT use API proposal: testObserver. Its package.json#enabledApiProposals-property declares: but NOT testObserver. The missing proposal MUST be added and you must start in extension development mode or use the following command line switch: --enable-proposed-api ms-python.python"Ung
@MarcusHagberg Then download the Pylance extension from the Marketplace and use the Extension top menu item Install from VSIXFootbridge
My marketplace has no "Pylance" extension, only the "Python" one which has Pylance in parenthesis. I am using the code - oss version on arch linux.Ung
what if you uninstall the python extension, and install it againFootbridge
Can you use this link to download and install into vscode:marketplace.visualstudio.com/…Bidden
@MarcusHagberg Have you tried the link posted by MingJieFootbridge
Yes, the command opened marketplace search for "ms-python.vscode-pylance" and that just shows the same "Python" extension. Re-installing it does nothing. Does anyone know what the error message I posted in first comment means? It comes from that same python extension.Ung
@Marcus Hagberg It seems to be caused because Python and Pylance extensions have a bit of a circular dependency: Python is declared as an extension pack which includes Pylance and Pylance has a dependency declared on the Python extension.For the first comment, I think you can refer to this article:github.com/microsoft/vscode-python/issues/16614Bidden
@MingJie I'm not sure that's relevant. The only prompt I have seen is that Pylance is not installed, and asking to install it, which does nothing. Nothing about reloading.I've added a picture to the OP for clarification.Ung
@Marcus Hagberg Please provide the vscode version number or try updating manuallyBidden
My vscode version: 1.65.2-1Ung
@Marcus Hagberg That doesn't seem to be the problem with the vscode version. Can you update the problem? I want to check that there is an entry called extension pack in the python extension you installed. Can you upload that part of the screenshot? There should be Python hereBidden
Updated now. Should there be a Pylance extension pack listed there? I only have JupyterUng
@MarcusHagberg On my system there is also the mention of Pylance extension in the pack, I'm using vscode-python v2021.12. Also look in the packake.json of microsoft.vscode-python for extensionPackFootbridge
So I found it a bit "suspicious" no one was commenting on the fact that I was using the strictly open source version of vscode, and found this page where they mention that not all extension are available on both versions, so since this was hindering my workflow I switched to the proprietary version, and Pylance is available and works now. Thanks for the help anyway.Ung
D
3

Pylance is not compatible with VSCodium. Even if you install it with the official Marketplace, Pylance will display this message:

You may install and use any number of copies of the software only with Microsoft Visual Studio, Visual Studio for Mac, Visual Studio Code, Azure DevOps, Team Foundation Server, and successor Microsoft products and services (collectively, the “Visual Studio Products and Services”) to develop and test your applications. [...]

You can eventually set python.languageServer setting to None, and use Pyright for type checking.

Doublefaced answered 10/10, 2023 at 9:48 Comment(0)
P
-1

Go to Settings > Extensions > Python, head down to Language Server and change Default to Pylance. This fix also works in the Open Source version, VS Codium. It should have nothing to do with the version of VScode you're using.

Petit answered 10/2, 2023 at 11:12 Comment(1)
This not working on VSCodium as in the above comment from Marcus Hagberg.Klutz

© 2022 - 2024 — McMap. All rights reserved.