Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code Pylance not highlighting variables and modules

I'm using VS Code with the Python and Pylance extensions. I'm having a problem with the Pylance extension not doing syntax highlight for things like modules and my dataframe. I would expect the modules at the top to be colored green and the df variable to be colored blue.

I am using the default Dark+ Color Theme.

Here's a screenshot of my VS Code with Python and Pylance installed an enabled.

Screenshot of VS Code

  • I have tried changing my python.pythonpath setting.
  • I've added a sys.path where my packages are installed.
  • I made sure to enable editor.semanticHighlighting.enabled in the settings.
  • Pylance is in my settings.json as the language server.
  • Also tried the most recent Pylance version.
  • Tried switching to various Dark/Light themes. No change in behavior.

Here is my settings.json

{
"[python]": {
    "editor.semanticHighlighting.enabled": true
},
"editor.semanticHighlighting.enabled": true,
"editor.semanticTokenColorCustomizations": {},
"python.condaPath": "C:\\Anaconda3\\Scripts\\conda-script.py",
"python.defaultInterpreterPath": "C:\\Anaconda3\\python.exe",
"python.pythonPath": "C:\\Anaconda3\\python.exe",
"python.languageServer": "Pylance",
"python.terminal.activateEnvironment": true

}

This was working last month so I'm not quite sure what's going on. I'm on Windows 10, VS Code 1.47.1, with the newest extensions. Any thoughts as to why this is happening?

like image 900
MyNameHere Avatar asked May 22 '26 01:05

MyNameHere


2 Answers

Looks like your Language Server does not work.

Could you add "python.languageServer": "Pylance", in the settings.json? Make sure the Pylance has been enabled. If it still does not work try to reinstall the Pylance and Python extension.

like image 131
Steven-MSFT Avatar answered May 23 '26 13:05

Steven-MSFT


Was running into the same problem in VSCode 1.88.1 (March 2024) on Windows with WSL. The PyLance extension must have gotten lost at some point... I installed it manually on the remote (clicked "Install in WSL: Ubuntu) in the extensions panel. It worked fine after that.

like image 30
YakovK Avatar answered May 23 '26 13:05

YakovK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!