[{
"resource": "/d:/Users/Home/Desktop/Python/estudos/pratices.py",
"owner": "_generated_diagnostic_collection_name_#0",
"code": {
"value": "reportMissingModuleSource",
"target": {
"$mid": 1,
"external": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingModuleSource",
"path": "/microsoft/pyright/blob/main/docs/configuration.md",
"scheme": "https",
"authority": "github.com",
"fragment": "reportMissingModuleSource"
}
},
"severity": 4,
"message": "Import \"pandas\" could not be resolved from source",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 8,
"endLineNumber": 1,
"endColumn": 14
}]
is the message given the cmd shell tells me i have all the libraries i want installed and they're in the project folder, i'm running a virtual environment but whenever i try to run something in a .py file, it says that it's not defined, i have installed anaconda but don't mean to use it right now, if i open a jupyter file it'll import no problem, but trying to run pip doesn't work at all
reinstalling vscode, making sure python's installed, making sure pip is installed
CodePudding user response:
I had a similar issue before and the solution I found is that you have to make sure the python interpreter for the current VSC window is your virtual environment instead of the system-wide python interpreter. On windows:
- Press F1
- Search for "interpreter".
- Click the python one
- Click "Enter interpreter path".
- Finally locate your virtual environment.
CodePudding user response:
You should make sure that the current interpreter and the pandas
library installed are the same interpreter environment.
The current interpreter can be output with the following code.
import sys
print(sys.executable)
Then install the pandas
library with the resulting interpreter path.
<the path obtained above> -m pip install pandas