问题
Both pandas and pandasql were installed via pip and are visible to the system/macos version of python. They are not visible to the brew installed python: they result in
ImportError: No module named pandas
I have tried the brew specific pip's as well:
$/usr/local/Cellar/python/2.7.14/libexec/bin/pip install pandasql
Requirement already satisfied: pandasql in /Library/Python/2.7/site-packages
Requirement already satisfied: numpy in /Users/sboesch/Library/Python/2.7/lib/python/site-packages (from pandasql)
Requirement already satisfied: sqlalchemy in /Library/Python/2.7/site-packages (from pandasql)
Requirement already satisfied: pandas in /Library/Python/2.7/site-packages (from pandasql)
Requirement already satisfied: pytz>=2011k in /Library/Python/2.7/site-packages (from pandas->pandasql)
Requirement already satisfied: python-dateutil in /Users/sboesch/Library/Python/2.7/lib/python/site-packages (from pandas->pandasql)
Requirement already satisfied: six>=1.5 in /Users/sboesch/Library/Python/2.7/lib/python/site-packages (from python-dateutil->pandas->pandasql)
So then why are pip/pip2 and the brew version of python disagreeing? How can this be fixed?
Note: I have also tried using the brew version of pip just to be sure: it gives the same results.
$which pip
/usr/local/Cellar/python/2.7.14/libexec/bin/pip
回答1:
Assuming brew at least installed Python correctly, a workaround to ensure its pip module is used is to explicitly use it like so
python -m pip install
If you want, you can alias pip-inst to redirect to that, so it's less typing
来源:https://stackoverflow.com/questions/47056147/why-does-brew-installed-python-not-see-the-pip-installed-modules