I had Python 2 and Python 3 installed in different directories, but I was facing this error, because when I was using the command pip install pandas
, it was installing Pandas in Python 2 directories while I was using Python 3.
So I had two directories with Python2 --> C:\Python27
and Python365 --> C:\Python365
.
To resolve this error:
Run pip install pandas
in cmd
. If library Pandas is already installed, you'll see something like the following.
pip install pandas
Requirement already satisfied: pandas in c:\python27\lib\site-packages (0.23.4)
Requirement already satisfied: python-dateutil>=2.5.0 in c:\python27\lib\site-packages (from pandas) (2.7.3)
Requirement already satisfied: numpy>=1.9.0 in c:\python27\lib\site-packages (from pandas) (1.14.4)
Requirement already satisfied: pytz>=2011k in c:\python27\lib\site-packages (from pandas) (2018.4)
Requirement already satisfied: six>=1.5 in c:\python27\lib\site-packages (from python-dateutil>=2.5.0->pandas) (1.11.0)
From the output of above command you can see that pandas
is installed in the Python2
directory, i.e. C:\python27\lib\site-packages
(0.23.4).
Run the python
command in cmd
to check which Python version are you running.
python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
You can see that I'm using Python3
while Pandas is installed in the Python2
directory.
To install Pandas and other libraries in Python3
go to the scripts folder in Python3 directory, i.e., C:\Python365\Scripts
.
Open a Command window and run pip install pandas
.
Or you can use the complete path of pip in the Python3 directory in cmd
to run the install
command, i.e., C:\Python365\Scripts\pip install pandas