简体   繁体   English

pip3:错误的解释器:没有这样的文件或目录

[英]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:像这样的情况正是为什么不再推荐直接运行pippip3原因,而是支持:

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.或者,更好的是,使用虚拟环境,这样您就可以依赖pythonpip是来自当前活动环境的命令这一事实,甚至不必担心它们在系统范围内的含义。


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 成为python3pip3默认值,请重做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 pipwhich 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.6pip存在于~/.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.

相关问题 bash:/home/khawar/.local/bin/pip3:/home/khawar/anaconda3/envs/AAAIFace/bin/python:错误的解释器:没有这样的文件或目录 - bash: /home/khawar/.local/bin/pip3: /home/khawar/anaconda3/envs/AAAIFace/bin/python: bad interpreter: No such file or directory Python / pip错误的解释器:没有这样的文件或目录 - Python/pip bad interpreter : no such file or directory 错误的解释器:运行 pip 时没有这样的文件或目录 - bad interpreter: No such file or directory when running pip pip: "/Volumes/HD: bad interpreter: 没有那个文件或目录 - pip: "/Volumes/HD: bad interpreter: No such file or directory pip install flask导致解释器错误:没有这样的文件或目录 - pip install flask results in bad interpreter: No such file or directory 错误的解释器:没有这样的文件或目录 - Bad interpreter: No such file or directory pip --version zsh:没有这样的文件或目录:usr/local/bin/pip3 - pip --version zsh: no such file or directory: usr/local/bin/pip3 在 ubuntu 16.04 中安装 pip 后出现错误“/usr/bin/python3.9: bad interpreter: No such file or directory” - Getting error “/usr/bin/python3.9: bad interpreter: No such file or directory” after installing pip in ubuntu 16.04 pip安装/usr/local/opt/python/bin/python2.7:错误的解释器:没有这样的文件或目录 - pip installation /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory IPython 3.5 返回“错误的解释器:没有这样的文件或目录” - IPython 3.5 returns “bad interpreter: No such file or directory”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM