【问题标题】:Why does brew installed python not see the pip installed modules?为什么 brew installed python 看不到 pip 安装的模块?
【发布时间】:2017-11-01 13:35:12
【问题描述】:

pandas 和pandasql 都是通过pip 安装的,并且对python 的系统/macos 版本可见。它们对安装的brew 不可见python:它们导致

ImportError: No module named pandas

我也尝试过brew 特定的点子:

 $/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)

那么为什么pip/pip2 和brew 版本的python 不一致呢?如何解决这个问题?

注意:我也尝试过使用pip 的brew 版本,以确保:它给出了相同的结果。

$which pip
/usr/local/Cellar/python/2.7.14/libexec/bin/pip

【问题讨论】:

  • Brew 将 Python 安装到 /usr/local。您的pip 显然是指系统/Library/ Python 安装。它们是两种不同的安装。
  • @deceze 那么brew python 使用了 which pip(或诸如pip2 之类的派生词)?我专门使用了brew中的pip! $which pip /usr/local/Cellar/python/2.7.14/libexec/bin/pip
  • pip2 不同,是的。在 that 上运行 which
  • 您可能只想使用 python -m pip install 并依赖 Python 安装本身

标签: python pip homebrew


【解决方案1】:

假设 brew 至少正确安装了 Python,确保使用其 pip 模块的解决方法是像这样显式使用它

python -m pip install 

如果你愿意,你可以使用别名 pip-inst 来重定向到那个,这样就不用打字了

【讨论】:

  • 虽然我已经接受并赞成这个答案 - 您是否对为什么 pip 无法正常工作有任何见解(即使它来自 /usr/local/Cellar/.. 下的 brew 安装)?跨度>
  • 试试brew医生?重启机器?新的终端会话?我真的不确定
猜你喜欢
  • 1970-01-01
  • 2017-06-14
  • 1970-01-01
  • 2018-06-09
  • 2015-10-18
  • 1970-01-01
  • 1970-01-01
  • 2021-06-04
  • 2023-01-30
相关资源
最近更新 更多