無法在安裝資料夾之外使用最新的 youtube-dl

無法在安裝資料夾之外使用最新的 youtube-dl

我最近從 github 安裝了 youtube-dl:https://github.com/rg3/youtube-dl

如果我在安裝資料夾中運行它,它就會起作用,如下所示:

$ cd /home/max/software/youtube-dl
$ bin/youtube-dl <url>

但如果我嘗試在其他地方使用它,我會收到此錯誤:

Traceback (most recent call last):
  File "/home/max/software/youtube-dl/bin/youtube-dl", line 3, in <module>
    import youtube_dl
ImportError: No module named youtube_dl

即使我提供了可執行檔的完整路徑,也會發生這種情況。我還嘗試將可執行檔複製到/usr/local/bin,並在那裡建立符號連結。

這是exe的實際內容:

#!/usr/bin/env python

import youtube_dl

if __name__ == '__main__':
    youtube_dl.main()

這可能與它加載的 python 有關嗎?which python給我/usr/bin/python

答案1

這篇文章針對這個問題提出了一些解決方案

https://stackoverflow.com/questions/18054500/how-to-use-youtube-dl-from-a-python-program

sudo pip install --upgrade youtube_dl

相關內容