AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1242139
Accepted
Geoff Langenderfer
Geoff Langenderfer
Asked: 2020-05-22 06:48:57 +0800 CST2020-05-22 06:48:57 +0800 CST 2020-05-22 06:48:57 +0800 CST

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

  • 772

在 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

我该如何解决?

python youtube-dl 20.04
  • 8 8 个回答
  • 18897 Views

8 个回答

  • Voted
  1. Best Answer
    Geoff Langenderfer
    2020-05-22T06:54:31+08:002020-05-22T06:54:31+08:00

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

    ❯ which python
    python not found
    

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

    ❯ python3 $(which youtube-dl) https://www.youtube.com/watch?v=0IE-CXNs6Sw
    [youtube] 0IE-CXNs6Sw: Downloading webpage
    
    • 14
  2. Prabhakar Prakash
    2020-05-22T06:59:47+08:002020-05-22T06:59:47+08:00

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

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

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

    sudo apt-get install python3
    

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

    sudo update-alternatives --install  /usr/bin/python python /usr/bin/python3 1000
    
    • 8
  3. UbuntuUser
    2020-08-29T13:54:58+08:002020-08-29T13:54:58+08:00

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

    sudo ln -s /usr/bin/python3 /usr/bin/python

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

    • 7
  4. Andy
    2020-07-24T01:17:54+08:002020-07-24T01:17:54+08:00

    我尝试在 ubuntu 20.04 中安装 youtube-dl 时遇到了完全相同的问题,并花了很长时间试图解决。在放弃的边缘,我从Canonical看到了这个,认为它看起来太简单但还是尝试了!问题解决了!

    sudo snap install youtube-dl

    • 3
  5. Matteo Paolucci
    2020-10-13T06:13:43+08:002020-10-13T06:13:43+08:00

    这适用于 ubuntu 20.04 LTS:

    nano $(which youtube-dl)
    

    然后将第一行(shebang 行,即 #!...)替换为

    #!/usr/bin/python3
    
    • 2
  6. Daniel
    2021-04-05T06:56:58+08:002021-04-05T06:56:58+08:00

    该python变量未设置,update-alternatives也将不起作用。让我们解决这个问题。

    之后,我们可以决定python使用哪个版本$ sudo update-alternatives --config python。

    安装 python 2 和 3 的替代品

    $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 2
    
    $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 3
    
    $ sudo update-alternatives --list python
    /usr/bin/python2
    /usr/bin/python3
    

    更改要使用的版本(v3 默认,因为更高优先级)

    $ sudo update-alternatives --config python
    
    There are 2 choices for the alternative python (providing /usr/bin/python).
    
      Selection    Path              Priority   Status
    ------------------------------------------------------------
    * 0            /usr/bin/python3   3         auto mode
      1            /usr/bin/python2   2         manual mode
      2            /usr/bin/python3   3         manual mode
    
    Press <enter> to keep the current choice[*], or type selection number:
    
    $ python --version
    Python 3.8.5
    
    • 1
  7. mivk
    2021-04-18T11:30:25+08:002021-04-18T11:30:25+08:00

    如果你不需要 python 2 而只需要 python 3,最简单的就是

    sudo apt install python-is-python3
    

    它实际上只是一个符号链接。包描述解释它:

    在 Ubuntu 中,所有 python 包都使用显式的 python3 或 python2 解释器,并且根本不使用未版本化/usr/bin/python的。一些第三方代码现在主要基于 python3,但可能使用/usr/bin/python.

    这是一个方便的包,它提供了一个符号链接来将解释器指向 /usr/bin/python当前的默认值python3。它可以提高与其他现代系统的兼容性,同时破坏一些过时的或第 3 方软件。

    • 1
  8. FlorianGreg
    2022-04-13T00:53:47+08:002022-04-13T00:53:47+08:00

    #Debian 11 #安装

    sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/bin/youtube-d

    youtube-dl -U

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

    sudo ln -s /usr/bin/python3 /usr/bin/python

    youtube-dl -U

    youtube-dl 是最新的 (2021.12.17)

    • 0

相关问题

  • 默认的字符编码是什么?

  • 如何使用 pynotify 创建可点击通知?

  • 有没有安装 Django 1.2.*(最新稳定版)的简单方法?

  • 为 Python 应用程序设置构建系统

  • 为我的 PPA 创建包时遇到问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve