pip3:错误的解释器:没有那个文件或目录 [英] pip3: bad interpreter: No such file or directory

查看:281
本文介绍了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.

我尝试过这样的事情:

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 Python 3.x 一起使用的 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,它覆盖了 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天全站免登陆