VS Code can't import Python.h (and another files)

I switched to VS Code and downloaded the cpython repository. I noticed that vs-code constantly complains that the file can’t import “Python.h” or some files from Include/internal.
There are no errors about this during compilation.

This is not a VS Code forum

Nonetheless, .h files are C header files. You’ve downloaded a repository, that contains a lot of C code. Try installing an extension to VS Code that gives syntax highlighting etc for C code.

VS Code doesn’t care what file is what (if you declare them as trusted), it just deals with text files. VS Code extensions complain all the time. Complaining quickly to catch a syntax error, before attempting a lengthy compile process is one benefit of them (and often the whole point).

Sorry! I won’t do that again.

Regarding the expansion. I downloaded all the necessary extensions for C/C++, that’s why I came here (although I shouldn’t have)

I just don’t know how core-devs works with VS Code. It’s clear why VS Code complains, I want to import files that are located in the parent directory, which can’t be done.
But I don’t understand how cor-devs deal with this

For what it’s worth [1] I think advice on setting up VS Code for CPython development is totally in-bounds…if you were asking for help getting some other C project working, that’d be different.

I see in the developer guide that there is a way to use VSCode via Github Codespaces, I wonder if the config file used for that would help you configure your local installation.

  1. not much! ↩︎

1 Like

I used this json file and enabled errorSquiggles. Of course, another error appeared. I looked at issue 10732 and it helped me! Only I added the includepath settings not to settings.json, but to c_cpp_properties.json and it worked!

1 Like