Monday 16 November 2020

Visual Studio Code - "go to definition" not working .

 This was happening on VSC "Version: 1.51.1" 

For example if I was to create the following test.py code 

<code>

def my_function():
  print("Hello from a function")

my_function()

</code>

Then I should be able to right click 'my_function' and get an option 'go to definition' which will take to to the above function.  Unfortunately I was getting a 'no definition' available message. 

To fix this open VSC . 

use Command + Shift + P ( Mac ) 








Search for 'settings.json' 

And add this to your code 

<code>

{
// Defines type of the language server.
"python.jediEnabled": false,
"python.languageServer": "Microsoft"
}

<code> 

Restart VSC .  This then resolved my issue for the code example given above.

 
However I discovered another issue 'Visual Studio Code unresolved import python ' 

Which I would get when clicking on imported code , for example if I clicked on 'selenium' here. 

from selenium import webdriver

The solution for me here was to click on 'Python 3.8.2 64-bit' and replace it for another one. 


No comments: