成功安装Python自家版软件后,运行`pip`会给出'找不到命令' [英] Running `pip` gives 'command not found' after successful Python homebrew install
问题描述
作为序言,我对终端非常不好,请耐心等待.
To preface, I am very bad with the terminal, please be patient with me.
当我运行pip
时,我得到:
zsh: command not found: pip
when I run pip
I get:
zsh: command not found: pip
我在brew上安装了python 2.7.11,这应该允许pip正常工作
当我运行echo $PATH
时,我得到
I have installed Python 2.7.11 with brew, which should allow pip to work
When I run echo $PATH
I get
/usr/local/sbin /Users/Nicolas/.composer/vendor/bin /Library/Frameworks/Python.framework/Versions/3.4/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin
我注意到/usr/local/bin/在其中,我知道这是brew可执行文件链接到的地方
I notice that /usr/local/bin/ is in there, which I understand is where brew executables are linked to
当我运行which -a python
时我会得到
/usr/local/bin/python
/usr/bin/python
因此-安装了两个Python.我猜一个是本地OSX,一个是自制软件.
当我运行which python
时,我得到
So-- two Python installs. I'm guessing one is the native OSX one and one is the homebrew install.
When I run which python
I get
/usr/local/bin/python
所以这是在调用python时运行的python,对吗?
当我运行ls -l $(which python)
时,我得到
So this is the python that gets run when python is called, right?
When I run ls -l $(which python)
I get
lrwxr-xr-x 1 Nicolas admin 34 Feb 3 14:26 /usr/local/bin/python -> ../Cellar/python/2.7.11/bin/python
我认为这是问题所在;我注意到有一个/python/2.7.11/libexec文件夹...
I think this is where the problem is; I notice that there is a /python/2.7.11/libexec folder...
我也尝试了brew unlink python && brew link python
无济于事
当我尝试brew list python | grep pip
时,我会得到很长的结果列表
when I try brew list python | grep pip
I get a very long list of results
这可能是最重要的
/usr/local/Cellar/python/2.7.11/libexec/pip/pip/__init__.py
我不知道如何从这里开始...我认为这与python/2.7.11/libexec
中的pip而不是python/2.7.11/bin
I don't know how to proceed from here... I think it has to do with pip being in python/2.7.11/libexec
instead of python/2.7.11/bin
我对这些东西大多数都不熟悉;我对终端机的了解非常有限.我不确定如何从这里继续.谢谢您的帮助.
I am not familiar with most of this stuff; my understanding of terminal is very limited. I am not sure how to proceed from here. Any and all help is appreciated, thanks.
推荐答案
我的背景
我遇到了同样的问题,我认为升级到OSX 10.11(El Capitan)后可能会出现.当尝试运行pip时,我得到了-bash: pip: command not found
,我也尝试了python -m pip
,它也不起作用(no module found
).尝试通过Homebrew取消链接和重新链接python无效.
My Background
I had this same problem, and I think it may have arisen after upgrading to OSX 10.11 (El Capitan). When trying to run pip, I got -bash: pip: command not found
I also tried python -m pip
which did not work either (no module found
). Trying to unlink and relink python through Homebrew did not work.
我能够通过Homebrew完全卸载并重新安装python,从而解决了该问题.
I was able to fix the problem by completely uninstalling and reinstalling python via Homebrew.
brew uninstall python && brew install python
如果您也想删除旧版本的python,请使用
If you want to remove older versions of python too, use
brew uninstall --force python && brew install python
我现有的所有pip安装都没有受到影响,并且在我运行pip freeze
时仍会列出所有这些.重新安装后,该二进制文件现在被符号链接到/usr/local/bin/pip
,而该文件以前不存在.奇怪的是,/usr/local/Cellar/python/2.7.11/bin/pip
中的实际二进制文件在重新安装之前也不存在.
None of my existing pip installs were affected, and are all still listed when I run pip freeze
. After the reinstall, the binary is now symlinked to /usr/local/bin/pip
, which did not exist before. Strangely, the actual binary in /usr/local/Cellar/python/2.7.11/bin/pip
did not exist before the reinstall either.
这篇关于成功安装Python自家版软件后,运行`pip`会给出'找不到命令'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!