“Bad Interpreter: No such file or directory"的原因是什么? [英] What is the cause of "Bad Interpreter: No such file or directory"?

查看:24
本文介绍了“Bad Interpreter: No such file or directory"的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 linux 机器上有一个 Python 虚拟环境.已经正常工作两周了,今天突然醒来,在环境中执行不了任何命令.例如,如果我尝试使用 pip list 或 jupyter notebook,这就是我得到的(env 是我的环境名称):

I have a Python virtual environment on my linux machine. It has been working fine for two weeks, but all of a sudden I woke up today, and while in the environment I can't execute any commands. For example, if I try to use pip list, or jupyter notebook, this is what I get (env is the name of my environment):

~/env/bin$ pip list
-bash: /home/ubuntu/env/bin/pip: /home/ubuntu/env/bin/python: bad interpreter: No such file or directory

基本上任何其他命令都会发生同样的事情,除了 Python.输入 python 可以很好地打开 Python shell.有趣的是,当我只在这种环境下使用 pip 时,它说的是 Anaconda.

The same thing happens with basically any other command, except Python. Typing python brings up the Python shell just fine. Interestingly it says Anaconda though, when I only used pip with this environment.

我试图找到这方面的信息,但它们似乎都与运行脚本有关.

I've tried to find info on this but they all seem to be pertaining to running scripts.

还要提一下,当我手动查看环境bin时,我安装的包都是绿色的,除了Python是红色的.

Also want to mention that when I manually look in the environment bin, the packages I installed are all there in green, except Python is in red.

提前致谢.

推荐答案

你有一个脚本 /home/ubuntu/env/bin/pip 并且脚本有 shebang #!/home/ubuntu/env/bin/python 但文件是不存在或不可执行.

You have a script /home/ubuntu/env/bin/pip and the script has shebang #!/home/ubuntu/env/bin/python but the file is either absent or is not executable.

检查文件 /home/ubuntu/env/bin/python 是否存在.检查它是否可以由当前用户执行(只需从命令行运行它).如果没有——你需要找到一个可以运行的可执行文件(例如,它可能是 /home/ubuntu/env/bin/python3),编辑 /home/ubuntu/的第一行env/bin/pip 修复shebang.

Check if the file /home/ubuntu/env/bin/python exist. Check if it can be executed by the current user (just run it from the command line). If not — you need to find out a working executable (for example, it could be /home/ubuntu/env/bin/python3), edit the first line of /home/ubuntu/env/bin/pip to fix the shebang.

这篇关于“Bad Interpreter: No such file or directory"的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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