youtube-dl /usr/bin/env: 'python': 没有这样的文件或目录

Geo*_*fer 6 python youtube-dl 20.04

在 Ubuntu 20.04 中,我们收到以下错误:

? lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal

? youtube-dl https://www.youtube.com/watch?v=b4mihzeFqGA
/usr/bin/env: ‘python’: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

Geo*_*fer 9

在 Ubuntu 20.04 中,python3是安装的默认值。该python变量没有设置:

? which python
python not found
Run Code Online (Sandbox Code Playgroud)

我们可以通过使用python3and来解决这个问题which

? python3 $(which youtube-dl) https://www.youtube.com/watch?v=0IE-CXNs6Sw
[youtube] 0IE-CXNs6Sw: Downloading webpage
Run Code Online (Sandbox Code Playgroud)


Pra*_*ash 7

我认为你的系统上缺少 python,所以,

首先检查你是否安装了python。要检查这一点,只需打开终端并输入python. 如果它显示 python 版本并提示然后输入退出 quit()

如果缺少 python,则使用以下命令安装它:

sudo apt-get install python3
Run Code Online (Sandbox Code Playgroud)

如果这没有帮助,请尝试以下命令:

sudo update-alternatives --install  /usr/bin/python python /usr/bin/python3 1000
Run Code Online (Sandbox Code Playgroud)

  • 这样做: sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1000 (2认同)

Ubu*_*ser 5

在 Ubuntu 20.04+ 中处理这个问题的最简单方法是将 python 符号链接到 python3:

须藤 ln -s /usr/bin/python3 /usr/bin/python

但是请注意,如果您安装其他依赖于旧版 Python 的 Python 程序,则在您删除符号链接并安装旧版 Python 或修复程序以使用 Python 3 之前,它们可能无法正常运行或工作。但是不再支持旧的 Python 版本,因此最好只使用可以在 Python 3 下运行的 Python 程序。

  • 或者将 `alias python=python3` 添加到您的 bashrc (2认同)