2
votes

I already installed it with pip3 install pandas and using python3.7 but when I try to import pandas and run the code error popping up.

Traceback (most recent call last): File "/Users/barbie/Python/Test/test.py", line 1, in import pandas as pd ModuleNotFoundError: No module named 'pandas'

and if I try to install again.. it says this.

pip3 install pandas Requirement already satisfied: pandas in /usr/local/lib/python3.7/site-packages (0.23.4) Requirement already satisfied: pytz>=2011k in /usr/local/lib/python3.7/site-packages (from pandas) (2018.9) Requirement already satisfied: numpy>=1.9.0 in /usr/local/lib/python3.7/site-packages (from pandas) (1.15.4) Requirement already satisfied: python-dateutil>=2.5.0 in /usr/local/lib/python3.7/site-packages (from pandas) (2.7.5) Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil>=2.5.0->pandas) (1.12.0)

2
Is your test.py using python or python3? In the same directory what does python --version or which python return?Ollie in PGH
when I create Test folder with Pycharm I choose 3.7 then isn't test.py too using python3.7? @OllieinPGHuser10753862
Have you tried installing any other module previously? and did it work? Is this the only python installation on your system?ParvBanks
default python2.7 comes with the mac. @ParvBanksuser10753862
One alternative is you could use Anaconda.. but it'll create entire new environment..tired and bored dev

2 Answers

0
votes

If you're using pycharm you can go to File -> Settings -> Project -> Project Interpreter.

There you'll get a list of all the packages installed with the current python that pycharm is using. There is a '+' sign on the right of the window that you can use to install new packages, just enter pandas there.

0
votes

Probably you have more than one installation of Python.

You should check where your installed packages should be saved with the following

import os
os.path

and then install using the following terminal instruction

pip3 install pandas -t /usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6

where, of course, you should substitute the path with the one that Python gives you as output.