It seems that I already have pandas downloaded but I can't seem to use it in my program
I am using a mac with version 10.12.6
Any help would be greatly appreciated
here is my console commands
➜ Downloads cat code.py
import pandas
➜ Downloads pip3 install pandas
Requirement already satisfied: pandas in /usr/local/lib/python3.6/site- packages
Requirement already satisfied: numpy>=1.7.0 in /usr/local/lib/python3.6/site-packages (from pandas)
Requirement already satisfied: python-dateutil>=2 in /usr/local/lib/python3.6/site-packages (from pandas)
Requirement already satisfied: pytz>=2011k in /usr/local/lib/python3.6/site-packages (from pandas)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/site-packages (from python-dateutil>=2->pandas)
➜ Downloads python code.py
Traceback (most recent call last):
File "code.py", line 1, in <module>
import pandas
ImportError: No module named pandas
➜ Downloads
If you want to use Python3 on a Mac under homebrew, you need to:
install Python3 with
brew install python3
install any Python3 packages with
pip3
rather thanpip
:pip3 install PACKAGE # e.g. pip3 install pandas
If Python3 is installed correctly under homebrew, you will see that
/usr/local/bin/python3
is a symlink to something in homebrew's Cellar:If that is not the case, you have either not installed Python3 or you had a previous installation and homebrew was reluctant to overwrite it. In which case, if you really want to run with homebrew's Python3, run:
and check again if it is a symlink.
Then, when you run any Python3 scripts, you either need to put the full path in your shebang:
or, run with:
or, if your PATH includes
/usr/local/bin
:You can check your PATH with:
and see if it has
/usr/local/bin
near the start - which is what you want if you use homebrew.If you have set up correctly, and you run:
it will report:
because homebrew installs package binaries into
/usr/local/bin
. If it tells you anything other than/usr/local/bin/python3
, then your PATH is incorrect and it needs setting both in your current session, with something like:and with a similar command in your login profile for subsequent login sessions - that will be something like
$HOME/.profile
, or$HOME/.bash_profile
if you usebash
.In general, if you are running homebrew, you should check your system health every now and then with:
and follow the good doctor's advice - he's pretty good - I trained him ;-)