Python pip3: bad interpreter: 没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51373063/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pip3: bad interpreter: No such file or directory
提问by floss
I am trying to install dependencies using pip3
command
我正在尝试使用pip3
命令安装依赖项
current scenario:
当前场景:
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
I have no idea why my pip3
command is not working.
我不知道为什么我的pip3
命令不起作用。
I have tried things like this:
我试过这样的事情:
brew link --overwrite python
回答by abarnert
You've got a whole slew of different Python installations, plus at least one former Python installation that you deleted.
您已经拥有大量不同的 Python 安装,以及您删除的至少一个以前的 Python 安装。
Situations like this are exactly why running pip
or pip3
directly is no longer recommended, in favor of:
像这样的情况正是不再推荐运行pip
或pip3
直接运行的原因,而是支持:
python3 -m pip install whatever
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 somePython 3.x, which may be any of the various ones you've installed.
这保证您绝对积极地运行pip
与任何python3
方式相配的 ,而pip3
只是意味着您正在运行pip
与某些Python 3.x 相配的 ,这可能是您安装的各种 Python 3.x 中的任何一个。
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.
或者,更好的是,使用虚拟环境,这样您就可以依赖于python
和pip
是来自当前活动环境的命令这一事实,甚至不必担心它们在系统范围内的含义。
But, if you want to know how you got into this mess and how to fix it:
但是,如果你想知道你是如何陷入这种混乱以及如何解决它的:
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
).
您的python3
命令可能来自 Homebrew Python(您可以检查;ls -l /usr/local/bin/python3
并查看它是否是 中某些内容的符号链接/usr/local/Cellar/python
)。
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.
您的pip3
命令来自不存在的 Python 3。最有可能的是,您安装了另一个 Python 3,它覆盖了pip3
Homebrew Python 3 中的 Python 3,然后将其卸载,留下了一个损坏的东西pip
。
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.
最简单的方法就是将rm /usr/local/bin/pip3
. 然后,假设您希望 Homebrew Python 成为您的默认值python3
和pip3
,请重做该brew link python
命令。如果它向您显示任何警告或错误,您还有其他事情需要解决。如果没有,/usr/local/bin/pip3
现在应该是 Homebrew 3.6 pip
,并且which pip3
应该选择/usr/local/bin/pip3
,一切都很好,直到下次安装另一个 Python 3 并覆盖一堆东西。
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.)
更好的解决方法是选择一种安装 Python 的方式——无论是 Anaconda、Homebrew、python.org 安装程序还是其他任何方式——并始终如一地使用它。卸载所有东西,重新安装你真正想要的那个,再也不碰其他的了。(不幸的是,您仍然会使用 Apple 的系统 Python 2.7,但如果您只使用 3.x,那没关系。)
回答by A. Attia
You can try to change the python version of pip by doingvim /path/to/pip
Then change the commented line (first line) with the desired version of Python.
您可以尝试更改 pip 的 Python 版本,方法是vim /path/to/pip
使用所需的 Python 版本更改注释行(第一行)。
回答by passedbylove
sudo apt install python[2|3]-pip
pip2 install ws4py==0.3.2
I've faced the same situation, after above, my program working properly, Ubuntu 16.04.6 amd64
我也遇到过同样的情况,经过上面之后,我的程序运行正常,Ubuntu 16.04.6 amd64
回答by hao
please check your python version on your current environment,ensure it's python3
请检查您当前环境中的python版本,确保它是python3