Pylance gives a "Import numpy could not be resolved" error when importing packages even though it was previously able to import them

Viewed 277

For whatever reason, Pylance has started to refuse to recognize libraries such as numpy and tcod, even though running the command "pip list" shows that I have installed them on my machine.

This problem began happening two days ago, even though it was fine the day before that.

The error message reads, "Import x could not be resolved Pylance(reportMissingImports)"

Running the command "python -m site" returns the following information:

sys.path = [
    '/home/username',
    '/usr/lib64/python38.zip',
    '/usr/lib64/python3.8',
    '/usr/lib64/python3.8/lib-dynload',
    '/home/username/.local/lib/python3.8/site-packages',
    '/usr/lib64/python3.8/site-packages',
    '/usr/lib/python3.8/site-packages',
]
USER_BASE: '/home/username/.local' (exists)
USER_SITE: '/home/username/.local/lib/python3.8/site-packages' (exists)

The problem happens in all of my vscode workspaces. This is what my settings file in my current workspace looks like:

{
    "python.autoComplete.extraPaths": [
    "/usr/lib64/python3.8/site-packages",
    "/home/username/workspace/python",
    "/home/username/.var/app/com.visualstudio.code/data/python/lib/python3.9/site-packages",
    "/username/bin/python3.8",
    "/home/username",
    "/usr/lib64/python38.zip",
    "/usr/lib64/python3.8",
    "/usr/lib64/python3.8/lib-dynload",
    "/home/username/.local/lib/python3.8/site-packages",
    "/usr/lib64/python3.8/site-packages",
    "/usr/lib/python3.8/site-packages",
    "/usr/local/lib64/python3.8/site-packages",
    "/var/data/python/bin"
    ],
    "python.defaultInterpreterPath": "/home/python38/python",
    "python.analysis.extraPaths": [
    "/sur/lib64/python3.8/site-packages",
    "/home/username/workspace/python",
    "/home/username/.var/app/com.visualstudio.code/data/python/lib/python3.9/site-packages",
    "/username/bin/python3.8",
    "/home/username",
    "/usr/lib64/python38.zip",
    "/usr/lib64/python3.8",
    "/usr/lib64/python3.8/lib-dynload",
    "/home/username/.local/lib/python3.8/site-packages",
    "/usr/lib64/python3.8/site-packages",
    "/usr/lib/python3.8/site-packages",
    "/usr/local/lib64/python3.8/site-packages",
    "/var/data/python/bin"
    ]
}

Here's my current workspace file:

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {}
}

Aside from the interpreter available at the default interpreter path, VSCode offers the the following available interpreters:

Python 3.9.7 (Recommended), located at /bin/python
Python 3.9.7, located at /sbin/python
Python 3.9.7, located at /usr/bin/python
Python 3.9.7, located at /usr/sbin/python

I've tried all of them as well as the entry for "python.defaultInterpreterPath" with no luck.

0 Answers
Related