Lucas
Lucas

Reputation: 411

Vscode can't use the function "go to definition" and can not open file in PROBLEMS

I'm using VScode for my python project on macOS, but I cannot use the function of go to definition and can not open file in PROBLEMS.

For example: when I control-click (macOS) and select go to definition, it raise a warning like this:

Unable to open 'spider.py': A system error occurred (ENOTDIR: not a directory, stat '/Users/gassy/Documents/python_spider/toutiao/spider.py/Users/gassy/Documents/python_spider/toutiao/spider.py').

Also, when I click an entry listed in PROBLEMS, it also give the same error: screenshot of the error

It seems like a problem creating the path to the file as the path is repeated in the error message like path/to/file.py/path/to/file.py

Go to Definition works for global variables.

System: macOS Mojave

Version: VScode 1.30.2

Upvotes: 3

Views: 9112

Answers (4)

Nam Lee
Nam Lee

Reputation: 1

Uninstall/Reinstall or Disable/Enable all extensions did not work for me.

Clearing all cache of VScode however helped me to solve this problem.
For this, delete all files from the cache folder: C:\Users\\{Your Username}\AppData\Roaming\Code

Upvotes: 0

Aro
Aro

Reputation: 1

The same problem happened to me.

And it turn out to be the Chinese path that caused this problem.

Copy the folder to a path that contains no Chinese character, and things work well for me

Upvotes: 0

hufang360
hufang360

Reputation: 21

You can install the extension pydev in vscode. The extension website is https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev

If you using Python3, Please visit the official website http://www.pydev.org/vscode/

Upvotes: 2

Lucas
Lucas

Reputation: 411

Finally ,I find the reason! I thought this bug may be produced by an extension, so I reinstalled VScode for many times followed the method of this website uninstall-remove-vscode-mac and tried to find the reason.

When I install Visual Studio IntelliCode, it ask me to install Microsoft Python Language Server. After that, this bug happened.

Hope this solution will help you.

Upvotes: 0

Related Questions