My lap is MacBookPro2017, macOS Mojave 10.14.16
I used to coding in Jupyter and everything goes well.
However when I want to do the same thing in VScode, it said that
"ImportError: No module named pandas"
I am sure I have installed pandas by
pip3 install pandas
I do following things:
1.Search for similar problems on SO, and someone says there may be more than one version python, the pip and pandas may under another path. Then I find there are python2.7 and python3.7 in my lap:
AlfiedeMacBook-Pro:~ alfie$ which python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
AlfiedeMacBook-Pro:~ alfie$ which python
/usr/bin/python
AlfiedeMacBook-Pro:~ alfie$ which pip
/Library/Frameworks/Python.framework/Versions/3.7/bin/pip
AlfiedeMacBook-Pro:~ alfie$ which pip3
/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3
AlfiedeMacBook-Pro:~ alfie$ which pandas
AlfiedeMacBook-Pro:~ alfie$ pandas --version
-bash: pandas: command not found
AlfiedeMacBook-Pro:~ alfie$ pip --version
pip 19.2.2 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
And if I type:
AlfiedeMacBook-Pro:~ alfie$ pip3 install pandas
Requirement already satisfied: pandas in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (0.25.1)
Requirement already satisfied: pytz>=2017.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pandas) (2019.2)
Requirement already satisfied: python-dateutil>=2.6.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pandas) (2.8.0)
Requirement already satisfied: numpy>=1.13.3 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pandas) (1.17.0)
Requirement already satisfied: six>=1.5 in ./Library/Python/3.7/lib/python/site-packages (from python-dateutil>=2.6.1->pandas) (1.12.0)
So I think I have pandas in the true path(?)
2.Then I saw some one use sys to append the path, so I write it in front of my code:
import sys
sys.path.append('/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages')
import numpy as np
import pandas as pd
Then I got:
ImportError: this version of pandas is incompatible with numpy < 1.13.3
your numpy version is 1.8.0rc1.
Please upgrade numpy to >= 1.13.3 to use this pandas version
But my numpy version is 1.17, I have upgraded.
So I just want know what I should do to make the pandas can be used in VScode?
In most cases this error in Python generally raised: You haven't installed Pandas explicitly with pip install pandas. You may have different Python versions on your computer and Pandas is not installed for the particular version you're using.
Press Ctrl + Shift + P keyboard combination, then select Python: Select Interpreter, choose the proper one with the packages you need installed, and the problem will be fixed.
1. Check pandas Version from Command or Shell mode. From a command line or shell run the pip list command to check the pandas version or get the list of the package installed with the currently installed version next to the package. If you don't have pandas installed then this command doesn't list it.
I had the same issue. The problem was that VS Code was using a different environment (shown in the lower left corner). Switching the environment there solved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With