[英]pip3: bad interpreter: No such file or directory
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
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 some Python 3.x, which may be any of the various ones you've installed.这可以保证你绝对正运行的pip
,与任何去python3
手段,而pip3
只是意味着你正在运行的pip
,与一些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.您的pip3
命令来自不存在的 Python 3。 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.最有可能的是,您安装了另一个 Python 3,它覆盖了 Homebrew Python 3 中的pip3
,然后将其卸载,留下了一个损坏的pip
。
The simplest thing to do is to just rm /usr/local/bin/pip3
.最简单的方法就是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.然后,假设您希望 Homebrew Python 成为python3
和pip3
默认值,请重做brew link python
命令。 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.如果没有, /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.更好的解决方法是选择一种安装 Python 的方式——无论是 Anaconda、Homebrew、python.org 安装程序还是其他任何方式——并始终如一地使用它。 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.) (不幸的是,您仍然会使用 Apple 的系统 Python 2.7,但如果您只使用 3.x,那没关系。)
You can try to change the python version of pip by doing您可以尝试通过执行以下操作来更改 pip 的 python 版本vim /path/to/pip
Then change the commented line (first line) with the desired version of Python.然后使用所需的 Python 版本更改注释行(第一行)。
I'll made an addition, maybe it can help to someone.我会补充一点,也许它可以帮助某人。
I have python3.9
installation at this moment, but I get an error message like TS reported:我现在已经安装了python3.9
,但是我收到了一个类似 TS 报告的错误消息:
/home/username/.local/bin/pip: bad interpreter: /usr/bin/python3.6: No such file or directory
I found that files pip3.6
and pip
exists in ~/.local/bin
direcotry with following shebang (note that explicit Python version specified):我发现文件pip3.6
和pip
存在于~/.local/bin
并带有以下 shebang(请注意,指定了显式 Python 版本):
#!/usr/bin/python3.6
But since I have not 3.6 version on my system, calling但是由于我的系统上没有 3.6 版本,因此调用
$ pip
obviously causes this error.显然会导致此错误。 Replacing 3.6
to 3.9
fixes it.将3.6
替换为3.9
修复了它。
I have the same problem.我也有同样的问题。
For me the path of python in venv/bin/pip
was wrong.对我来说venv/bin/pip
的 python 路径是错误的。
1. Open pip: 1.打开点子:
gedit path/to/pip gedit路径/到/pip
#!/home/saeed/project-master/venv/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
2. Correct the python path in the first line of pip
file: 2.修正pip
文件第一行的python路径:
#!/home/saeed/project/venv/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
请检查您当前环境中的python版本,确保它是python3
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
解决方案( apt update && topgrade )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.