-2

I have two versions of Python installed in my mac: Python2.7 and python 3.7. When I try to install Pandas using Pip,

pip install pandas

It shows,

Requirement already satisfied: pandas in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (0.25.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: 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: pytz>=2017.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pandas) (2019.1)
Requirement already satisfied: six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas) (1.12.0)

Upon Importing pandas, it prompts an error: No Module Found.

Raghus-MacBook-Pro:~ Home$ python Python 2.7.16 (default, Aug  6 2019, 11:00:03)  [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: No module named pandas

I have also tried ,

sudo pip install pandas

But it doesn't solve my issue. Pandas gets imported with python3. But i want pandas to be imported with python. Is it the Problem with the Directory? Help me out.

Raghu Ram
  • 1
  • 1
  • 1

2 Answers2

2

Your default py version is python2.7.
Whereas, you're installing pandas on py3.
Try

pip2 install pandas

to install on py2.7

1

If your goal is to run python 3 instead of python 2, it might be a good idea to use an conda environment to create a project-specific python 3 environment in which you install pandas. Then you can use the package from there.

so you install anaconda and type this

conda create -n pandaenv
conda activate pandaenv
conda install pip
pip install pandas
python
>>> import pandas

you might also replace line 3 and 4 by

conda install pandas
  • Why is conda better than venv? I've never heard of conda :| – Artog Aug 07 '19 at 07:50
  • I guess you can do the same with venv or pipenv. I never used them, but the benefit of conda is that it manages packages for you based on the dependencies. So if I type e.g. "conda install tensorflow" it suggests a whole list of packages for me to install. – Harm Campmans Aug 07 '19 at 11:37