Reputation: 311
I've been trying to use the packages pandas, numpy, matplotlib, seaborn in my "Visual Studio Code", but the program keeps showing me the following message:
"import pandas could not be resolved from source Pylance(reportMissingModuleSource)"
Previously to Visual Studio Code I installed "Anaconda" to use Jupyter, and now it says that i have the existing packages (pandas, numpy...) but keeps appearing this message that doesn't allow me to use pandas in my Visual Studio.
Anyone could help me to solve this issue?
I tried installing again all the packages to check if they didn't exist but apparently are installed all of them but in another route. I can't find how is the way to put them so the Visual Studio Code recognizes them and I can use them.
Upvotes: 31
Views: 147902
Reputation: 91
First, Uninstall pylance extensions from your VS Code. Close the VS Code, Reopen the VS Code, install pylance again.
It works for me!
Upvotes: 9
Reputation: 36
If you have ensured that Python version at the bottom right of VSCode and Python version installed in your system is the same and are still facing this issue -
Enter this in your VS code terminal -
python -m pip install <package_name>
This worked for me. Hope its useful.
Upvotes: 0
Reputation: 568
Check the version of your python being run from the IDE as stated in this answer: VS Code: ModuleNotFoundError: No module named 'pandas'
Upvotes: 0
Reputation: 1180
I also received similar an error on my IDE VSCode and currently using mac m1 .First we need to make sure that the python3 interpreter version from terminal version is the same with our python version selection in VSCode.
open your IDE VSCode
open any/current folder that related to python project on IDE VSCode
Check your python version at the bottom right on IDE VSCode (in my case the python version is 3.10.64)
change or switch VSCode python version from 3.10.64 to 3.9.12 (same with your python version on your pc)
done
Upvotes: 44
Reputation: 16
In my case (Mac User), I have 2 python versions (version2, version3)
VScode looks for version2, so I need to install pandas for version3 by
pip3 install pandas
then change VScode path setting to the python3 installation folder. You can check the folder by terminal command:
python3 -version
Then go to VScode setting and type Python Path in search box, and you will see Default Interpreter Path, then paste the new path of your python3
for your reference my path is /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
Upvotes: 0
Reputation: 39
Maybe the environment path for python was changed, and thus the problem.
For me it was: 'C:\Program Files\Python311\Scripts', and not 'C:\Program Files\Python311'
Upvotes: 0
Reputation: 11
You should choose the right version of python at the bottom right of VSCode with the python version that you have installed.
Upvotes: 1
Reputation: 173
You should install pandas again using current active python interpreter. For example if your current interpreter is located in:
C:\Users\[username]\AppData\Local\Programs\Python\Python311
then you should install pandas using this command:
C:\Users\[username]\AppData\Local\Programs\Python\Python311\python.exe -m pip install pandas
Note that you can find your current interpreter by clicking on the python version at the bottom right of Vscode.
Upvotes: 1
Reputation: 1159
My VSCode Python extension had in its settings, a default interpreter path that was an invalid leftover. Even if the interpreter selected at the bottom right for running the file was the correct one, this caused the problem reporter to encounter issues.
I went into settings and reset the entry for python.defaultInterpreterPath
.
Upvotes: 0
Reputation: 51
I encountered this problem in VSCode under remote to WSL2 of Windows 10. The Python version is correct as interpreter (3.9.13) and the terminal in VSCode is also under the same envs (ie. VSCode ran "conda activate xx" and (xx) is shown in prompt)
Originally, I tried to install the pandas by the following command.
sudo apt-get install python3-pandas
Pandas was installed successfully as stated in the terminal but the problem is still there.
When I try to install pandas by the following command, the problem solved.
pip install pandas
Upvotes: 5
Reputation:
Another way I solved this issue having followed every other installation process to the letter was deactivating Pylance. Works a (py)charm now.
Upvotes: 1
Reputation: 119
Also, you can click on the interpreter version at the bottom left corner of the screen (Vs.code 2022) it should show a dropdown menu with a list of the available and selected python interpreter. Click on add interpreter path and paste the path to the python interpreter with all the required modules installed and click enter. This should resolve the problem.
Upvotes: 8
Reputation: 21
I also had this problem and it was because of version mismatches.
I had installed Python AND Anaconda. If anyone else has done this and gets this error, you need to uninstall both. Then install Anaconda only; Python (the compatible version) is installed as part of that process.
See https://docs.anaconda.com/anaconda/install/windows/
Upvotes: 2
Reputation: 17
I re-entered the path to Python interpreter and warning disappeared. Hope that helps you.
Upvotes: 0