pip3:错误的解释程序:没有这样的文件或目录 [英] pip3: bad interpreter: No such file or directory

查看:901
本文介绍了pip3:错误的解释程序:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用pip3命令安装依赖项

I am trying to install dependencies using pip3 command

当前情况:

Dev$ which python
/Users/Dev/anaconda/bin/python

Dev$ which python3
/usr/local/bin/python3


Dev$ pip --version
pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)

Dev$ pip3 --version
-bash: /usr/local/bin/pip3: /usr/local/opt/python3/bin/python3.6: bad 
interpreter: No such file or directory

我不知道为什么我的pip3命令不起作用.

I have no idea why my pip3 command is not working.

我已经尝试过这样的事情:

I have tried things like this:

brew link --overwrite python 

推荐答案

您有很多不同的Python安装,以及至少一个以前删除的Python安装.

You've got a whole slew of different Python installations, plus at least one former Python installation that you deleted.

正因为如此,不再建议直接运行pippip3的原因正是如此:

Situations like this are exactly why running pip or pip3 directly is no longer recommended, in favor of:

python3 -m pip install whatever

这保证您绝对肯定运行python3所代表的pip,而pip3仅意味着您正在运行 some 所伴随的pip. Python 3.x,它可能是您安装的各种版本中的任何一个.

This guarantees that you're absolutely positively running the pip that goes with whatever python3 means, while pip3 just means you're running the pip that goes with some Python 3.x, which may be any of the various ones you've installed.

或者甚至更好地使用虚拟环境,因此您可以依靠以下事实:pythonpip是当前活动环境中的命令,而不必担心它们在系统范围内的含义.

Or, even better, use virtual environments, so you can rely on the fact that python and pip are the commands from the currently-active environment, and not even worry about what they mean system-wide.

但是,如果您想知道自己是如何陷入困境以及如何解决该问题的话:

But, if you want to know how you got into this mess and how to fix it:

您的python3命令可能来自Homebrew Python(您可以检查; ls -l /usr/local/bin/python3并查看它是否是/usr/local/Cellar/python中某些内容的符号链接).

Your python3 command is probably from a Homebrew Python (you can check; ls -l /usr/local/bin/python3 and see if it's a symlink to something in /usr/local/Cellar/python).

您的pip3命令来自不存在的Python 3.最有可能的是,您安装了另一个Python 3,该Python 3从Homebrew Python 3覆盖了pip3,然后将其卸载,从而留下了损坏的pip.

Your pip3 command is from a Python 3 that doesn't exist. Most likely, you installed another Python 3, which overwrote the pip3 from the Homebrew Python 3, and then uninstalled it, leaving a broken pip behind.

最简单的操作就是rm /usr/local/bin/pip3.然后,假设您希望将Homebrew Python用作python3pip3的默认设置,请重做brew link python命令.如果它显示任何警告或错误,则您还有其他要解决的问题.如果没有,那么/usr/local/bin/pip3现在应该是Homebrew 3.6 pip,而which pip3应该选择/usr/local/bin/pip3,一切都很好,直到下次安装另一个Python 3并覆盖一堆东西为止.

The simplest thing to do is to just rm /usr/local/bin/pip3. Then, assuming you want your Homebrew Python to be your default for python3 and pip3, redo the brew link python command. If it shows you any warnings or errors, you still have other things to fix. If not, /usr/local/bin/pip3 should now be the Homebrew 3.6 pip, and which pip3 should pick out /usr/local/bin/pip3, and everything is good until the next time you install another Python 3 and overwrite a bunch of stuff.

一个更好的解决方法是选择一种安装Python的方法,无论是Anaconda,Homebrew,python.org安装程序,还是其他方法,并始终使用.卸载所有内容,重新安装您真正想要的一个,再也不要碰其他任何一个. (不幸的是,您仍然会使用Apple的系统Python 2.7,但是如果只使用3.x,那就没关系了.)

A better fix would be to pick one way of installing Python—whether Anaconda, Homebrew, python.org installers, or whatever—and use that consistently. Uninstall everything, reinstall the one you actually want, and never touch the others again. (Unfortunately, you will still be stuck with Apple's system Python 2.7, but if you're only using 3.x, that won't matter.)

这篇关于pip3:错误的解释程序:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆