Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No definition found for function - VSCode Python

I am using VSCode for Python along with the Microsoft for Python extension enabled in VSCode.

For Python v3.9.0 I am getting No definition found if I try to seek a function definition.

enter image description here

However, I do not get the error if I use my Conda Virtual environment for Python 3.7.0

What might be the problem?

like image 858
Mihir Avatar asked Oct 08 '20 04:10

Mihir


People also ask

Why is definition disabled in Visual Studio?

Answers. Don't close Visual Studio but close all the files and open them again by clicking on the file in the solution. The file might have been opened by Source Safe or you maybe opened it from Windows Explorer. In this case the file doesn't get assosiated with your solution and the Go to Def.


2 Answers

When I used the code you provided and disabled the Python extension, I encountered the same problem as you.

Since "Go to Definition" is supported by the corresponding language service extension, it is recommended that you check that the current Python extension is available and confirm that the selected python interpreter is also available. In addition, please try to reload VSCode.

like image 70
Jill Cheng Avatar answered Nov 14 '22 21:11

Jill Cheng


I had the same problem and changing the python language server from Jedi to Microsoft or Pylance did fix the problem. To do this go to the settings with Cntrl + , and search for python.languageserver

like image 32
Bart Avatar answered Nov 14 '22 22:11

Bart