【问题标题】:Getting Fabric to work on Mountain Lion using Homebrew and PIP使用 Homebrew 和 PIP 让 Fabric 在 Mountain Lion 上工作
【发布时间】:2012-10-16 22:49:49
【问题描述】:

我似乎无法让 Fabric 正常运行。我发现这篇文章没有解决我的问题Getting Fabric Python Library to Work

我使用 Homebrew brew install python 安装了 Python(这也安装了 PIP):

运行which python 我明白了:

/usr/local/Cellar/python/2.7.3/bin/python

然后我安装了织物pip install fabric

Requirement already satisfied (use --upgrade to upgrade): fabric in /usr/local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): ssh>=1.7.14 in /usr/local/lib/python2.7/site-packages (from fabric)
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.1,!=2.4 in /usr/local/lib/python2.7/site-packages (from ssh>=1.7.14->fabric)

另一篇文章建议fabric将位于/usr/local/Cellar/python/2.7.1/bin/fab

在上面执行ls(但在我的情况下为 2.7.3)得到以下结果(无织物)。

lrwxr-xr-x   1 darron  staff   80 Oct 26 17:37 2to3 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/2to3
lrwxr-xr-x   1 darron  staff   82 Oct 26 17:37 2to3-2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/2to3-2
lrwxr-xr-x   1 darron  staff   84 Oct 26 17:37 2to3-2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/2to3-2.7
-r-xr-xr-x   1 darron  staff  422 Oct 26 17:37 easy_install
-r-xr-xr-x   1 darron  staff  430 Oct 26 17:37 easy_install-2.7
lrwxr-xr-x   1 darron  staff   80 Oct 26 17:37 idle -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/idle
lrwxr-xr-x   1 darron  staff   81 Oct 26 17:37 idle2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/idle2
lrwxr-xr-x   1 darron  staff   83 Oct 26 17:37 idle2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/idle2.7
-r-xr-xr-x   1 darron  staff  380 Oct 26 17:37 pip
-r-xr-xr-x   1 darron  staff  388 Oct 26 17:37 pip-2.7
lrwxr-xr-x   1 darron  staff   81 Oct 26 17:37 pydoc -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pydoc
lrwxr-xr-x   1 darron  staff   82 Oct 26 17:37 pydoc2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pydoc2
lrwxr-xr-x   1 darron  staff   84 Oct 26 17:37 pydoc2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7
lrwxr-xr-x   1 darron  staff   82 Oct 26 17:37 python -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python
lrwxr-xr-x   1 darron  staff   89 Oct 26 17:37 python-config -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python-config
lrwxr-xr-x   1 darron  staff   83 Oct 26 17:37 python2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python2
lrwxr-xr-x   1 darron  staff   90 Oct 26 17:37 python2-config -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python2-config
lrwxr-xr-x   1 darron  staff   85 Oct 26 17:37 python2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x   1 darron  staff   92 Oct 26 17:37 python2.7-config -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x   1 darron  staff   83 Oct 26 17:37 pythonw -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pythonw
lrwxr-xr-x   1 darron  staff   84 Oct 26 17:37 pythonw2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pythonw2
lrwxr-xr-x   1 darron  staff   86 Oct 26 17:37 pythonw2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x   1 darron  staff   84 Oct 26 17:37 smtpd.py -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/smtpd.py
lrwxr-xr-x   1 darron  staff   87 Oct 26 17:37 smtpd2.7.py -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/smtpd2.7.py
lrwxr-xr-x   1 darron  staff   85 Oct 26 17:37 smtpd2.py -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/smtpd2.py

我在/usr/local/lib/python2.7/site-packages找到了实际安装位​​置

drwxr-xr-x  14 darron  staff   476 Oct 26 17:41 Crypto
drwxr-xr-x   9 darron  staff   306 Oct 26 17:41 Fabric-1.4.3-py2.7.egg-info
drwxr-xr-x  10 darron  staff   340 Oct 26 17:37 distribute-0.6.28-py2.7.egg
-rw-r--r--   1 darron  staff   237 Oct 26 17:37 easy-install.pth
drwxr-xr-x  10 darron  staff   340 Oct 26 17:41 fabfile
drwxr-xr-x  41 darron  staff  1394 Oct 26 17:41 fabric
drwxr-xr-x   7 darron  staff   238 Oct 22 08:13 git_remote_helpers
lrwxr-xr-x   1 darron  staff    93 Oct 22 08:13 git_remote_helpers-0.1.0-py2.7.egg-info -> ../../../Cellar/git/1.8.0/lib/python2.7/site-packages/git_remote_helpers-0.1.0-py2.7.egg-info
drwxr-xr-x   4 darron  staff   136 Oct 26 17:37 pip-1.2.1-py2.7.egg
drwxr-xr-x   7 darron  staff   238 Oct 26 17:41 pycrypto-2.6-py2.7.egg-info
-rw-r--r--   1 darron  staff   144 Oct 26 17:37 setuptools-0.6c11-py2.7.egg-info
-rw-r--r--   1 darron  staff    34 Oct 26 17:37 setuptools.pth
-rw-r--r--   1 darron  staff  1224 Oct 26 17:37 sitecustomize.py
-rw-r--r--   1 darron  staff   600 Oct 26 17:37 sitecustomize.pyc
drwxr-xr-x  72 darron  staff  2448 Oct 26 17:41 ssh
drwxr-xr-x   8 darron  staff   272 Oct 26 17:41 ssh-1.7.14-py2.7.egg-info

我的问题是如何让它工作?在提示符下运行 fab 让我:

-bash: fab: command not found

注意 - 我的路径设置在 /etc/paths 中,如下所示:

/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin

【问题讨论】:

  • 你考虑过并且可以使用 virtualenv 吗?

标签: python-2.7 pip osx-mountain-lion homebrew fabric


【解决方案1】:

您发布的链接已过时。 fab 应该位于 /usr/local/share/python 目录中——Homebrew 的 Python 将已安装模块中的脚本放在该目录中。将/usr/local/share/python 添加到您的PATH

【讨论】:

  • 是的,已经解决了。谢谢
  • 这很好奇。我只是安装了fabric,它在/usr/local/lib/python2.7/site-packages/,没有/usr/local/share/python。这是安装了最新的pythonpython@2 软件包。
最近更新 更多