I'm guessing that this
This is the problem the tab pops up.
Import "credentials" could not be resolved
isn't an error coming from the Python interpreter, because it does not look like the standard "ModuleNotFoundError: No module named 'XXX'", which is what you get when you run your Python code and your imports are wrong or misconfigured.
Since you mentioned Visual Studio Code and a "tab", then I'm guessing that's coming from an integrated linter and it's displaying that error in the Problems tab:

If credentials
is indeed in the same directory as that file, and you are running your code under the same directory, then
import credentials
should be fine. The problem is only with the linter, it does not know where to look for credentials
. Depending on which linter you have enabled (see the Linting Python in Visual Studio Code section of the docs), you'll have to explicitly tell your linter where to find credentials
.
For example, assuming you have a folder app
that contains credentials
and this script:
app
├── ...(other files)...
├── credentials.py
└── script.py
Add/update a .vscode/settings.json file on your workspace (see the General linting settings section of the VS Code docs). I'm using Pylance so I need to add a python.analysis.extraPaths
list entry like this:
"python.analysis.extraPaths":[
"/absolute/path/to/app"
]
to basically tell my linter that "when checking imports, also check this app
folder". That clears the "could not be resolved" from the Problems tab.