Intellisense not working in Jupyter Notebook in VSCode
Asked Answered
G

5

8

Intellisense and the coloring of code is no longer working in my Jupyter Notebook in VSCode. It was working perfectly fine before then I reloaded the window(like I have done before without issue) and it doesn't work any more. enter image description here enter image description here

I tried reloading, resetting the kernel, uninstalling Jupyter, and checking if any other extensions were causing this issue, but nothing seems to work. I have been stuck on this for so long and I have no idea what could have caused it or how to fix it.

Update: I further discovered that this only happens within the specific virtual environment that I am working in. Jupyter works fine outside of this environment.

Update 2: The issue seems to happen in any virtual environment, even new ones that I created to test it in.

Gallardo answered 2/3, 2023 at 19:4 Comment(2)
If you could find exact steps to reproduce this, that would be greatConnotative
I only reloaded the window and cleared cache a few times in quick succession. Maybe this corrupted or reset a config file?Gallardo
A
11

A guess is that the setting of python.languageServer was none in your settings.json. I encountered the same problem after an update before.

Add the following codes to your settings.json, this works for me:

"python.languageServer": "Pylance",
Adrianaadriane answered 3/3, 2023 at 1:36 Comment(9)
Thanks, I tried it but still giving the same issue.Gallardo
Another guess, have you installed the extension of Dependency Analytics? Try to disable it.Adrianaadriane
Yea I checked that too but I don't have it installed. And I even uninstalled all other extensions.Gallardo
Did you check whether highlight works in .py file? If it works, I suggest you installing pre-version of jupyter.Adrianaadriane
Yes it works in .py files, I tried uninstalling and reinstalling jupyter but that did not work. I will try installing a previous version.Gallardo
This problem should be solved in Dec last year according to this issue in github. I think there is something wrong with your extension or vscode itself. Try to reinstall them one by one may work.Adrianaadriane
FWIW, this solution worked for meGalbraith
Worked for me on Mac, VSCode Version: 1.85.2. Thanks!Fortunato
This worked for me when I added that line to my user's settings.json. However, it does not work with pandas when you do something like: df[masking].some_function(). It looks like Pylance gets confused.Irairacund
L
3

adding "python.languageServer": "Pylance", worked for me.

How to open settings.json :- go to setting in bottom, search autocomplete and then chose python and then click on edit on settings.json

enter image description here

Louralourdes answered 13/9, 2023 at 12:22 Comment(1)
After installation of the Pylance extension, I also added the line below in the user settings.json (not sure if this has any impact but it worked for me after restarting vscode). "python.autoComplete.extraPaths": ["C:\\Program Files\\Python311\\python.exe"],Satchel
F
2

I've been having a similar problem since I upgraded to MacOS Sonoma. Intellisense worked fine in .py files, but didn't work in .ipynb files.

I was able to resolve this by closing vscode, and then opening it with all extensions disabled. If you're on a mac, use this command in terminal code --disable-extensions or if you're using OhMyZSH, the shortcut is vscde. You can also do it via the command palette in vscode. I used the terminal method.

Once opened, there's no intellisense, obviously. But vscode gave me a prompt to reload with extensions enabled. I clicked that, the window reloaded and I had intellisense working again in my python notebooks.

Facesaving answered 6/10, 2023 at 5:43 Comment(2)
This also worked for me on the latest code-insiders, still on MacOS Ventura, using Remote Development extensions. A regular reload, exit+reopen, upgrading versions hadn't helped didn't help.Parsaye
Worked for me today with standard VsCode. Started code with code --disable-extensions, clicked on Reload with extension and autocomplete is back. Thanks.Sprocket
A
1

In addition to setting "python.languageServer": "Pylance", setting "python.analysis.extraPaths" to /path/to/your/venv/lib/python<version>/site-packages in json settings worked for me to get VS Code's Intellisense working for a Jupyter notebook installation via pip in a virtualenv. Also, setting the kernel to the running Jupyter server at localhost:8888 might be required...

Agenesis answered 3/2, 2024 at 2:53 Comment(0)
H
0

What worked for me was adding "jupyter.enableExtendedPythonKernelCompletions": true, to the settings.json.

This can, however, impact cell execution performance according to the setting description and uses the Jedi language server.

Hypsometer answered 25/9, 2024 at 9:9 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.