Reputation: 2161
I use the Mac terminal to check my package:
pip list
I can find all packages including Pandas:
But when I
import pandas
it told me:
ModuleNotFoundError: No module named 'pandas'
By the way, I have Python 2 and Python 3 on my Mac. They are not the same directory, and I suspect the Python interpreter didn't find the path of Pandas.
Upvotes: 30
Views: 130908
Reputation: 4594
I tried almost every suggestion under this question, but I still faced the issue and after a lot of struggle, I resolved this by the below steps.
Run the command prompt as administrator and then enter the below.
pip install pandas
It helps you resolve the issue.
Upvotes: 0
Reputation: 5098
If Python 2.7 is already installed, then to install NumPy and Pandas for v2.7, run the below commands:
For Ubuntu / Linux -
sudo apt-get install python-numpy
sudo apt-get install python-pandas
If Python 3 is already installed, then to install NumPy and Pandas for v3, run the below commands:
For Ubuntu / Linux -
sudo apt-get install python3-numpy
sudo apt-get install python3-pandas
Upvotes: 8
Reputation: 41
The error I saw was:
File "c:\SIP\python\visualws\learn1\pandas_test.py", line 6, in import pandas as pd ModuleNotFoundError: No module named 'pandas'
I executed the below command in Windows using Python 3.9.5:
pip install pandas
Collecting pandas
Downloading pandas-1.2.4-cp39-cp39-win_amd64.whl (9.3 MB)
|████████████████████████████████| 9.3 MB 3.3 MB/s
Collecting pytz>=2017.3
Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
|████████████████████████████████| 510 kB 6.8 MB/s
Collecting numpy>=1.16.5
Downloading numpy-1.20.3-cp39-cp39-win_amd64.whl (13.7 MB)
|████████████████████████████████| 13.7 MB ...
Collecting python-dateutil>=2.7.3
Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
|████████████████████████████████| 227 kB 6.4 MB/s
Collecting six>=1.5
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, pytz, python-dateutil, numpy, pandas
Successfully installed numpy-1.20.3 pandas-1.2.4 python-dateutil-2.8.1 pytz-2021.1 six-1.16.0
WARNING: You are using pip version 21.1.1; however, version 21.1.2 is available.
You should consider upgrading via the 'c:\users\deepy\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command.
It solved the problem and I was able to execute the .py file with import pandas
.
Upvotes: -1
Reputation: 1
Sometimes, it might be due to an issue with Microsoft Visual C++.
For that, first you need to install Microsoft Visual C++ using the instructions given in Error "Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)"
After successful installation, use pip install pandas
to install Pandas
If pip
is not installed, then download the Pandas source package with extension tar.gz
and place it in directory wherever you want after extracting. Open cmd.exe
and navigate to the path where the Pandas folder is extracted & placed using cd C:/pandas
. Then install it using the python setup.py install
Finally you should get the success message as
Finished processing dependencies for pandas==0.xx.0
Upvotes: 0
Reputation: 6650
First of all, install virtualenv
inside your project folder to secure your project directory to avoid conflict with your other packages.
pip install virtualenv
After installing this, run this command one by one inside your root project directory:
virtualenv venv
source venv/bin/activate
Now your directory is secure and you can install your required packages inside.
pip install pandas
and others as you required.
Because you have installed virtualenv
and running as secure, it will not conflict with other outside packages.
Use these all steps one by one.
Upvotes: 24
Reputation: 341
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
Upvotes: 4