Python, VSCode

Python + VSCode: “Go to Definition” Doesn’t Work?

Make sure that you have Microsoft’s Python extension installed. If you need more than one paths, simply create a .env file in project root path, and add extra paths in, separated by :, as such:

PYTHONPATH=libs/python:/another/python

VSCode will know to look for definitions under these paths.

If it still doesn’t work, or doesn’t work all the time, it’s very likely that one of the other plugins that you have is interfering with the Python one. To check, use Command + Shift + P to open the prompt and run the command:

> Extensions: Open Extensions Folder

Move all the extensions there to another temporary place, re-install the Python extension, and see if things start working now. If it does work now, add them back in batch to find out the culprit. 😀

Also, for gigantic projects, try switching intellisense engine:

Try switching off Jedi

Standard

2 thoughts on “Python + VSCode: “Go to Definition” Doesn’t Work?

  1. Xiaokang Wang says:

    Thanks for your blog, which helps me solve this problem. “Got to definition” feature is very handy when navigate through a project.

    In fact, my situation is slightly different. I am using VScode to connect to a remote Linux computer. Some extensions are installed on the remote computer. The logic is the same. I went to ~/.vscode-server/extensions and delete all the extensions, then reinstall python extension. It worked!

    Could I connect with you via social media?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.