Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't run in python 2.6.1: function keywords must be strings (was: youtube-dl totally broken: call always echoes same traceback) #3813

Closed
AFineTransform opened this issue Sep 22, 2014 · 12 comments

Comments

@AFineTransform
Copy link

@AFineTransform AFineTransform commented Sep 22, 2014

I installed youtube-dl using Homebrew on Mac OS 10.6.8 via brew install youtube-dl. The installation seemed to proceed flawlessly, but every call to youtube-dl does nothing and returns the same traceback. For instance, here's the result of youtube-dl --version:

Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/runpy.py", line 121, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "/usr/local/bin/youtube-dl/__main__.py", line 18, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 430, in main
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 136, in _real_main
  File "/usr/local/bin/youtube-dl/youtube_dl/options.py", line 112, in parseOpts
TypeError: __init__() keywords must be strings

But I get the same result with a video URL, the help flag, or even if I call it with no options. To my untrained eyes, it seems like the program is failing to recognize the command line options as strings, which would explain why it can't get very far, since they are involved in every useful program call. I don't know enough about python to confirm this, however.

I have python 2.6 and 3.4 on my system:

$ python --version
Python 2.6.1
$ python3 --version
Python 3.4.1

youtube-dl seems to have taken to version 2.6, but both versions should be compatible.

I also installed rtmpdump and ffmpeg using brew, but they don't seem to have anything to do with this problem.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Sep 22, 2014

This seems to be a problem in old python versions: http://bugs.python.org/issue2646. It works with python 2.6.8, 2.7.8 and 3.4.1. You could just upgrade to python 2.7 (If you want to use python 3 and are using bash, you can use an alias: alias youtube-dl="python3 $(which youtube-dl)").

@phihag What should we do here, transform the dictionary keys with str?

@AFineTransform
Copy link
Author

@AFineTransform AFineTransform commented Sep 22, 2014

Perfect! Forcing it to use python 3.4.1 solved this issue. I was kind of hoping it would have used python 3 anyway.

Should I close? Since it was a problem with the supposedly supported python 2.6, I can see why you'd want this to remain open.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Sep 22, 2014

I'd keep it open, since we try to fully support python 2.6.

@jaimeMF jaimeMF changed the title youtube-dl totally broken: call always echoes same traceback Doesn't run in python 2.6.1: function keywords must be strings (was: youtube-dl totally broken: call always echoes same traceback) Sep 22, 2014
@phihag
Copy link
Contributor

@phihag phihag commented Sep 22, 2014

@AFineTransform By default, youtube-dl will be executed using the default Python on your machine (the one that runs when you just enter python).

@phihag
Copy link
Contributor

@phihag phihag commented Sep 22, 2014

I don't see any reason to support any 2.6 versions but the newest (or the one that travis uses). Since this seems to be a fundamental bug in the 2.6 interpreter, the easiest remedy should be to detect this horrible brokenness and warn users to use a different interpreter.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Sep 22, 2014

It makes sense. It seems that it was fixed in 2.6.5: https://hg.python.org/cpython/file/v2.6.5/Misc/NEWS#l64

@cprior
Copy link

@cprior cprior commented Nov 14, 2014

This breaks sl4a support with 2.6.2 available.
http://rg3.github.io/youtube-dl/ says "2.6, 2.7...“ supported!

I am not the bug reporter but in real-world I'd reject the "solution to use the latest 2.6".

@AlbertoGP
Copy link

@AlbertoGP AlbertoGP commented Nov 14, 2014

I'm having this problem in a NAS (small Linux server with ARM CPU and RAID), where the python version in the firmware image is 2.6.2.
Since I'm using Python only for this I don't care what version I have, and I've installed python3 with ipkg, at version 3.2.3.
Installing software in such environments is more complicated. In this case after installing python3 I had to create a symbolic link to make it override the built-in python:
ln -s /opt/bin/python3 /opt/bin/python

Now it fails with a different error message:

Traceback (most recent call last):
  File "/opt/lib/python3.2/runpy.py", line 160, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/opt/lib/python3.2/runpy.py", line 73, in _run_code
    exec(code, run_globals)
  File "/[path-omitted]/youtube-dl/__main__.py", line 15, in <module>
  File "/[path-omitted]/youtube-dl/youtube_dl/__init__.py", line 58
    setproctitle(u'youtube-dl')
                             ^
SyntaxError: invalid syntax

I'll use another computer, but it would be nice to have the possibility of doing this directly there.

@phihag
Copy link
Contributor

@phihag phihag commented Nov 14, 2014

@AlbertoGP Note that Python 3.2 is unsupported in youtube-dl (2.6, 2.7 or 3.3+ is required).

@cprior
Copy link

@cprior cprior commented Nov 15, 2014

Which version of youtube-dl introduced the change breaking "2.6” compatibility and required 2.6.5 or higher?

Is there a chance at least YouTube downloads still work with that version?

@AlbertoGP
Copy link

@AlbertoGP AlbertoGP commented Nov 15, 2014

I've just submitted a workaround for the Unicode dict keys bug in Python 2.6.0-2.6.4, at #4205
It works in my NAS with Python 2.6.2, tested with a couple of YouTube videos.

@phihag phihag closed this in c7b0add Nov 15, 2014
@phihag
Copy link
Contributor

@phihag phihag commented Nov 15, 2014

I believe this issue to be fixed in youtube-dl 2014.11.15.1 and newer. See our FAQ if you have problems updating.

Note that while this means that youtube-dl will work on these really old Python versions, you are at your own risk using such horribly outdated code: You may run into issues both general and specific to youtube-dl, and may suffer from well-known security vulnerabilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.