[英]pip install on OS X Mavericks fails with error: /usr/local/bin/pip: No such file or directory
I am running the Python 2.7.5 version that came standard with OSX. 我正在运行OSX标配的Python 2.7.5版本。
I have tried to install pip using sudo easy_install pip AND python get-pip.py 我试图使用sudo easy_install pip和python get-pip.py安装pip
When I try to install pip I get the following error with easy_install: 当我尝试安装pip时,我使用easy_install收到以下错误:
Processing pip
Running setup.py -q bdist_egg --dist-dir /Users/XXXX/pip/egg-dist-tmp-VtRwku
warning: no files found matching 'pip/cacert.pem'
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
no previously-included directories found matching 'tasks'
pip 1.6.dev1 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
error: /usr/local/bin/pip: No such file or directory
When I try to install pip with get-pip.py 当我尝试使用get-pip.py安装pip时
Requirement already up-to-date: pip in /Library/Python/2.7/site-packages/pip-1.6.dev1-py2.7.egg
@ mirra.p the problem is probably you have two versions of python 2 installed on your PC in different locations and pip of one of the copies of python got removed somehow. @ mirra.p问题可能是你在不同位置的PC上安装了两个版本的python 2,其中一个python的副本被删除了某种方式。 so when you try to install the pip for a copy, system says that there is a pip already installed in another location and also the /usr/local/bin folde is also missing the pip file used to installed pip.
因此,当您尝试为副本安装pip时,系统会说已经在另一个位置安装了一个pip,并且/ usr / local / bin folde也缺少用于安装pip的pip文件。
already installed pip file's location is this: 已经安装了pip文件的位置是这样的:
Library/Python/2.7/site-packages/pip-1.6.dev1-py2.7.egg 图书馆/ Python的/ 2.7 /站点包/ PIP-1.6.dev1-py2.7.egg
i just solved this issue so i will try to explain it in a way so that beginners also understand it properly 我刚刚解决了这个问题所以我会尝试以某种方式解释它,以便初学者也能正确理解它
copy the already installed pip file to the location where it is missing instead of installing it through commands as command will detect the already installed pip. 将已安装的pip文件复制到缺少的位置,而不是通过命令安装它,因为命令将检测已安装的pip。
the solution is very simple: 解决方案很简单:
run these commands in a terminal (command prompt) in Ubuntu 在Ubuntu中的终端(命令提示符)中运行这些命令
to get the location of the pip file already installed 获取已安装的pip文件的位置
which pip
哪个点子
cp <location provided by which pip> <location where to copy pip file>
cp /Library/Python/2.7/site-packages/pip /usr/local/bin
cp /Library/Python/2.7/site-packages/pip / usr / local / bin
i used the locations for mirra.p problem. 我使用mirra.p问题的位置。
hope it helps. 希望能帮助到你。
The error message and especially the additional diagnostics in comments mentioning Cellar
indicate that you have installed another Python version using Homebrew. 错误消息,尤其是提及
Cellar
评论中的其他诊断信息表明您已使用Homebrew安装了另一个Python版本。
Probably simply renaming /usr/local/bin/pip
to something else will fix the immediate problem. 可能只需将
/usr/local/bin/pip
重命名为其他内容即可解决当前问题。 I'll advise against removing it entirely, at least until you understand what precisely is wrong. 我会建议不要完全删除它,至少在你明白究竟是什么问题之前。
In more detail; 更详细; to use the system Python, you have to undo whatever Homebrew did when it installed a second Python.
要使用系统Python,你必须撤消Homebrew在安装第二个Python时所做的任何事情。 For a start, you need to unset all the variables which
brew
installed (or made you install) in your .bashrc
and other locations previously. 首先,您需要取消设置之前在
.bashrc
和其他位置安装(或安装) brew
所有变量。
If you have orphaned symbolic links in /usr/local/bin
which point to locations where no command is installed any longer, you'll want to simply remove those (needs root access). 如果
/usr/local/bin
有孤立的符号链接指向不再安装命令的位置,则只需删除那些(需要root访问权限)。 This is a sign of a dirty uninstall; 这是一个脏卸载的标志; next time, follow the Homebrew instructions for how to remove it and the packages you installed with it.
下次,按照Homebrew说明,了解如何删除它以及随之安装的软件包。
In more detail, Howebrew will have done something like 更详细的说,Howebrew会做类似的事情
ln -s /usr/local/Cellar/something/something/python-2.7.3 /usr/local/bin/python
and if /usr/local/Cellar/something/something
now no longer exists, attempting to write something there through the symlink will obviously fail. 如果
/usr/local/Cellar/something/something
现在不再存在,尝试通过符号链接写一些东西显然会失败。 This seems to be exactly what the pip
installer is attempting to do at the very end of the installation. 这似乎正是
pip
安装程序在安装结束时尝试做的事情。
If you have removed Homebrew permanently, you can edit .bashrc
and revert whatever changes Homebrew required there. 如果您永久删除了Homebrew,则可以编辑
.bashrc
并恢复Homebrew所需的任何更改。 Some settings may remain active in your already-running shell instances until the next reboot; 某些设置可能会在您已运行的shell实例中保持活动状态,直到下次重新启动为止 if you want to fix those, read on.
如果你想解决这些问题,请继续阅读。
To temporarily override settings, you can unset
your PYTHONPATH
to get back the system default behavior. 要临时覆盖设置,可以
unset
PYTHONPATH
以恢复系统默认行为。 If you have commands in /usr/local/bin
shadowing the system default ones, you can temporarily set your PATH
to prefer /usr/bin
by simply prepending it (this is a temporary hack only); 如果你在
/usr/local/bin
有命令遮蔽系统默认值,你可以暂时将你的PATH
设置为prefer /usr/bin
,只需预先设置它(这只是一个临时的hack);
PATH=/usr/bin:$PATH
The shell commands are suitable for Bash; shell命令适用于Bash; if you use another shell, adapt accordingly.
如果您使用另一个shell,请相应调整。
If you are getting error: /usr/local/bin/pip: No such file or directory
and pip
already is installed, do following things to solve this problem: 如果您收到错误:
/usr/local/bin/pip: No such file or directory
和pip
,请执行以下操作来解决此问题:
which pip
. which pip
。 It will give answer like : /usr/local/bin
/usr/local/bin
here, 这里,
cp /usr/local/bin /usr/local/bin/pip
This solved my problem. 这解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.