1

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

E_net4
  • 27,810
  • 13
  • 101
  • 139
Lucas
  • 321
  • 1
  • 3
  • 7
  • 1
    https://stackoverflow.com/questions/53939751/pylint-unresolved-import-error-in-visual-studio-code explains how to modify .vscode/settings.json by adding "python.autoComplete.extraPaths": ["./path-to-your-code"] – Jason Harrison Dec 02 '20 at 23:56

3 Answers3

2

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/

hufang360
  • 21
  • 2
  • Welcome to Stack Overflow. Answers that are just a little more than a link may be deleted. Please ensure your answer is useful by adding some more information. – Joey Apr 15 '19 at 23:17
0

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.

Lucas
  • 321
  • 1
  • 3
  • 7
  • 2
    What was your solution regarding `Microsoft Python Language Server`? Did you just ignored the VS Code prompt and did not install it? – tonix Dec 09 '19 at 12:28
0

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

Aro
  • 1