youtube-dl doesn't work

youtube-dl https://www.youtube.com/watch?v=b2nF9k4_FOo
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/bin/youtube-dl/__main__.py", line 16, in <module>
  File "/usr/bin/youtube-dl/youtube_dl/__init__.py", line 15, in <module>
  File "/usr/bin/youtube-dl/youtube_dl/options.py", line 8, in <module>
  File "/usr/bin/youtube-dl/youtube_dl/downloader/__init__.py", line 3, in <module>
  File "/usr/bin/youtube-dl/youtube_dl/downloader/common.py", line 9, in <module>
  File "/usr/bin/youtube-dl/youtube_dl/compat.py", line 22, in <module>
ImportError: No module named xml.etree.ElementTree


Anyone has please solved it ?

Edit: I’ve tried

youtube-dl -U

and latest version from https://youtube-dl.org/

Python 2 was almost completely removed from Tumbleweed (I believe only basic interpreter remains to satisfy requirements of some major projects). Where does you copy come from? youtube-dl in Tumbleweed is built against Python 3.

zypper if youtube-dl 
Loading repository data...
Reading installed packages...


Information for package youtube-dl:
-----------------------------------
Repository     : Main Repository (OSS)
Name           : youtube-dl
Version        : 2020.06.06-1.1
Arch           : noarch
Vendor         : openSUSE
Installed Size : 1.8 MiB
Installed      : Yes (automatically)
Status         : up-to-date
Source package : youtube-dl-2020.06.06-1.1.src
Summary        : A tool for downloading from video sites for offline watching
Description    : 
    youtube-dl is a small command-line program to retrieve videos from
    YouTube.com and other video sites for later watching.


(TUMBLEWEED 32 bit. )

I am not using TW, but Leap 15.1. In my system youtube-nl comes from Packman. Did you do the Vendor switch to Packman as is advised in the sticky threads of the Multi-media sub-forums (better fitting I guess then the Applications sub-forum you choose).

Yes, it works:

karl@erlangen:~> youtube-dl  https://www.youtube.com/watch?v=b2nF9k4_FOo
https://www.youtube.com/watch?v= Merging formats into "openSUSE Tumbleweed w_KDE Overview _ Distro Delves S2 -Ep17-b2nF9k4_FOo.mp4"
Deleting original file openSUSE Tumbleweed w_KDE Overview _ Distro Delves S2 -Ep17-b2nF9k4_FOo.f299.mp4 (pass -k to keep)
Deleting original file openSUSE Tumbleweed w_KDE Overview _ Distro Delves S2 -Ep17-b2nF9k4_FOo.f140.m4a (pass -k to keep)
karl@erlangen:~> 

Hi
Likewise, updating it probably reverts to python2 which won’t work…


youtube-dl  https://www.youtube.com/watch?v=b2nF9k4_FOo
https://www.youtube.com/watch?v= Destination: openSUSE Tumbleweed w_KDE Overview _ Distro Delves S2 -Ep17-b2nF9k4_FOo.f299.mp4


zypper se -i youtube-dl

S | Name                       | Summary                                                               | Type
--+----------------------------+-----------------------------------------------------------------------+--------
i | python3-youtube-dl         | A Python module for downloading from video sites for offline watching | package
i | youtube-dl                 | A tool for downloading from video sites for offline watching          | package
i | youtube-dl-bash-completion | Bash completion for youtube-dl                                        | package

[QUOTE=malcolmlewis;2938734]Hi
Likewise, updating it probably reverts to python2 which won’t work…


youtube-dl  https://www.youtube.com/watch?v=b2nF9k4_FOo
https://www.youtube.com/watch?v=
erlangen:~ #

** packman**** Haupt-Repository (OSS)**

Hi
Mine are all from oss, don’t use packman or non-oss here :wink:


zypper se -is youtube-dl
Loading repository data...
Reading installed packages...

S | Name                       | Type    | Version        | Arch   | Repository
--+----------------------------+---------+----------------+--------+----------------------
i | python3-youtube-dl         | package | 2020.06.06-1.1 | noarch | Main Repository (OSS)
i | youtube-dl                 | package | 2020.06.06-1.1 | noarch | Main Repository (OSS)
i | youtube-dl-bash-completion | package | 2020.06.06-1.1 | noarch | Main Repository (OSS)

Snapshot 20200617 changed things again:

erlangen:~ # zypper se -is youtube-dl
Loading repository data...
Reading installed packages...

S  | Name                       | Type    | Version          | Arch   | Repository
---+----------------------------+---------+------------------+--------+-----------
i+ | youtube-dl                 | package | 2020.06.16.1-1.1 | noarch | packman
i  | youtube-dl-bash-completion | package | 2020.06.16.1-1.1 | noarch | packman
erlangen:~ # 

Change logs are pretty terse:

* Tue Jun 16 2020 Mathias Homann <Mathias.Homann@opensuse.org>
- Updated to version 2020.06.16.1

* Mon Jun 15 2020 Mathias Homann <Mathias.Homann@opensuse.org>
- Updated to version 2020.06.16

* Fri Jun 05 2020 Mathias Homann <Mathias.Homann@opensuse.org>
- Updated to version 2020.06.06

Both versions work fine.

Another perspective: Flathub has a program called Video Downloader that has most of the same functionality as youtube-dl and youtube-dl-gui.

I just installed youtube-dl-2021.02.04.1-1.1 from packman and I’m getting this message when downloading a video:

/usr/bin/env: ‘python’: No such file or directory

Python38 is installed. There is no /usr/lib/env directory. Do I need to create a link to python38?

Hi
No, Packman need to fix the package naming convention… report a bug (PackMan :: Documentation) or on the ML…

Thank you.

Hi
Delete the Packman version and install The openSUSE Tumbleweed version, it only needs ffmpeg present.

I got a response from Steven Swart from packman:

“As I recall, I may be wrong, but the binary naming conventions for Python is that ‘python’ is for legacy Python 2, if you want to invoke Python 3, you have to explicitly call ‘python3’.
This is how both versions can coexist on one installation. Ino general, Python 2 scripts are not compatible with Python 3.
You may need to install Python 2. As I recall though, it will be deprecated soon, or already has been.”

As far as installing the Tumbleweed version, I only found python38-youtube-dl in that repo and I got the same error about a missing directory.

youtube-dl works fine here. Try:

[FONT=monospace]**erlangen:~ #** zypper install youtube-dl 
Loading repository data... 
Reading installed packages... 
'youtube-dl' is already installed. 
No update candidate for 'youtube-dl-2021.02.04.1-1.1.noarch'. The highest available version is already installed. 
Resolving package dependencies... 
Nothing to do. 
**erlangen:~ #**[/FONT]

This package is explicitly built to use python3:

PYTHON="%_bindir/python3" %make_build

so if you really get “same error about missing python” this means you do not use youtube-dl from this package.

Evan more so as python38-youtube-dl is Python module and does not install any executable at all. This module does have some files that upstream start with “!/usr/bin/env python” but these lines are removed when package is built.

youtube-dl in Tumbleweed is provided by - gasp - youtube-dl package. That package installs single binary that embeds Python code and it does not invoke “/usr/bin/env python”.

So you apparently continue to use some other version of youtube-dl (Packman?) which was not adjusted and still contains Python2 dependency. That is something to be fixed in Packman. While python2 interpreter may still be present, all needed Python2 modules are likely to have been removed at this point (as the original post shows).

Okay I’ve got it working now. The only youtube-dl I could find that wasn’t from packman was in the Tumbleweed:Factory repo which I didn’t have enabled. Thanks for the help.

Hi
Well technically Factory is Tumbleweed, but is in the oss repo?


zypper if youtube-dl

Information for package youtube-dl:
-----------------------------------
Repository     : Main Repository (OSS)
Name           : youtube-dl
Version        : 2021.01.24.1-1.1