VScode does not seem to accept interpreter from virtual environment

Viewed 1696

I am using the remote SSH option in VSCode to access a server, where I created a Python virtual environment.

The issue is that whenever I launch VSCode, it keeps showing the following error message:

enter image description here

However, when I click Select Python Interpreter, it shows me that my custom environment is indeed selected (the one marked as Current):

enter image description here

Additionally, I keep getting warnings that say: Import "package_name" could not be resolved from sourcePylancereportMissingModuleSource whereas package_name (e.g. Pandas) is installed in env.

I added the following lines to my settings.json:

"python.pythonPath": "/path_of_my_home_dir/env/bin/python"

and

"python.analysis.extraPaths": [
    "/path_of_my_home_dir/env/bin"
]

but it's still not recognizing the environment.

Note that my code runs properly. It's just that seeing these warnings is confusing.

Is there a way to fix this?

1 Answers

I find similar issue in github and one solution post by engineers is adding the following configuration in User Settings.json:

"python.experiments.optInto": [
        "pythonDiscoveryModule",
    ]

Then reload window.

Please have a try and see if the error goes away.

[UPDATE]

This seems to be a bug, you could comment that you've met the similar question under this issue or put a bug report by yourself to let engineers know and fix it.

Related