ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.19k stars 10.02k forks source link

TypeError: __init__() keywords must be strings #6762

Closed gilles-c closed 9 years ago

gilles-c commented 9 years ago

First, since 2 months ago approximately with Mac OS 10.6, I try to use youtube-dl with Python 3.4 ;

tmp root# PATH=/Library/Frameworks/Python.framework/Versions/3.4/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Developer/usr/bin/ but youtube-dl continue to use my old Python 2.6

Second, since 2 months ago approximately I have compiled libav 11.4. Until this day youtube-dl was working.

Third, youtube-dl is up to date ; tmp root# youtube-dl --version2015.09.03

Since the update of today, youtube-dl does not work and I read this error ;

youtube-dl -f 18 --verbose https://www.youtube.com/watch?v=aMgaJgwQUoE

[debug] System config: [] [debug] User config: [] [debug] Command-line args: [u'-f', u'18', u'--verbose', u'https://www.youtube.com/watch?v=aMgaJgwQUoE'] [debug] Encodings: locale US-ASCII, fs utf-8, out US-ASCII, pref US-ASCII [debug] youtube-dl version 2015.09.03 [debug] Python version 2.6.1 - Darwin-10.8.0-i386-64bit [debug] exe versions: avconv 11.4, avprobe 11.4 [debug] Proxy map: {} [youtube] aMgaJgwQUoE: Downloading webpage 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 19, in File "/usr/local/bin/youtube-dl/youtube_dl/init.py", line 410, in main File "/usr/local/bin/youtube-dl/youtube_dl/init.py", line 400, in _real_main File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1653, in download File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 655, in extract_info File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 287, in extract File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 992, in _real_extract File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 438, in _download_webpage File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 345, in _download_webpage_handle File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 326, in _request_webpage File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1860, in urlopen File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 383, in open response = self._open(req, data) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 401, in _open '_open', req) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 361, in _call_chain result = func(*args) File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 754, in https_open File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 1087, in do_open h = http_class(host, timeout=req.timeout) # will parse host:port File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 595, in _create_http_connection TypeError: init() keywords must be strings

gilles-c commented 9 years ago

Another example ; root# youtube-dl -f 18 --verbose https://www.youtube.com/watch?v=efIiQtfR7BI[debug] System config: [] [debug] User config: [] [debug] Command-line args: [u'-f', u'18', u'--verbose', u'https://www.youtube.com/watch?v=efIiQtfR7BI'] [debug] Encodings: locale US-ASCII, fs utf-8, out US-ASCII, pref US-ASCII [debug] youtube-dl version 2015.09.03 [debug] Python version 2.6.1 - Darwin-10.8.0-i386-64bit [debug] exe versions: avconv 11.4, avprobe 11.4 [debug] Proxy map: {} [youtube] efIiQtfR7BI: Downloading webpage 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 19, in File "/usr/local/bin/youtube-dl/youtube_dl/init.py", line 410, in main File "/usr/local/bin/youtube-dl/youtube_dl/init.py", line 400, in _real_main File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1653, in download File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 655, in extract_info File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 287, in extract File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 992, in _real_extract File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 438, in _download_webpage File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 345, in _download_webpage_handle File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 326, in _request_webpage File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1860, in urlopen File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 383, in open response = self._open(req, data) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 401, in _open '_open', req) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 361, in _call_chain result = func(*args) File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 754, in https_open File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 1087, in do_open h = http_class(host, timeout=req.timeout) # will parse host:port File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 595, in _create_http_connection TypeError: init() keywords must be strings mon-ordi:tmp root#

dstftw commented 9 years ago

[debug] Python version 2.6.1

Update python to some recent version.

gilles-c commented 9 years ago

I already updated Python to Python 3.4, but youtube-dl still use the old 2.6 ; I use this path ; root# PATH=/Library/Frameworks/Python.framework/Versions/3.4/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Developer/usr/bin/ but youtube-dl continue to use my old Python 2.6 as youtube-dl verbose says. Read again carefully my first post.

dstftw commented 9 years ago

Post the output of python --version.

gilles-c commented 9 years ago

root# python --version Python 2.6.1

dstftw commented 9 years ago

As you can see you did not update it. Recheck PATH contains the path to the new python before the path to the old python.

gilles-c commented 9 years ago

I use printenv to check PATH, his output ;

tmp root# printenv TERM=xterm-color SHELL=/bin/sh OLDPWD=/var/root USER=root PATH=/Library/Frameworks/Python.framework/Versions/3.4/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Developer/usr/bin/ PWD=/tmp SHLVL=1 HOME=/var/root _=/usr/bin/printenv ***End of printenv******

Python 3.4 is first, but python --version and youtube-dl still use 2.6.1, I did not understand !

dstftw commented 9 years ago

Maybe it's /System/Library/Frameworks/Python.framework/Versions/3.4/bin/:...?

gilles-c commented 9 years ago

Yes, probably because I have a link from Current to 2.6 ; mon-ordi:tmp root# cd /System/Library/Frameworks/Python.framework/Versions/ mon-ordi:Versions root# ls -ail total 8 1041998 drwxr-xr-x 6 root wheel 204 Mar 24 2014 . 1041997 drwxr-xr-x 7 root wheel 238 Mar 24 2014 .. 1066437 drwxr-xr-x 8 root wheel 272 Mar 24 2014 2.3 1045004 drwxr-xr-x 12 root wheel 408 Mar 24 2014 2.5 1041999 drwxr-xr-x 12 root wheel 408 Mar 24 2014 2.6 1066400 lrwxr-xr-x 1 root wheel 3 Mar 24 2014 Current -> 2.6

Does I must create a new link from Current to /Library/Frameworks/Python.framework/Versions/3.4 ?

gilles-c commented 9 years ago

I have unlinked Current ;

mon-ordi:Versions root# unlink Current mon-ordi:Versions root# ls -ail total 0 1041998 drwxr-xr-x 5 root wheel 170 Sep 4 18:48 . 1041997 drwxr-xr-x 7 root wheel 238 Mar 24 2014 .. 1066437 drwxr-xr-x 8 root wheel 272 Mar 24 2014 2.3 1045004 drwxr-xr-x 12 root wheel 408 Mar 24 2014 2.5 1041999 drwxr-xr-x 12 root wheel 408 Mar 24 2014 2.6

but I didn't Know if Current was a file or was a directory and I don't know How to link to /Library/Frameworks/Python.framework/Versions/3.4

I never understand ln -s, can you help ?

yan12125 commented 9 years ago

If you are installing the official Python from https://www.python.org/, there's no 'python' in /Library/Frameworks/Python.framework/Versions/3.4/bin/. You need to create one by hand. For example:

cd /Library/Frameworks/Python.framework/Versions/3.4/bin/
ln -s python3 python
gilles-c commented 9 years ago

I have installed Python from https://www.python.org/ftp/python/3.4.3/python-3.4.3-macosx10.6.pkg

On Terminal I haved ;

mon-ordi:Versions root# cd /Library/Frameworks/Python.framework/Versions/3.4/bin/ mon-ordi:bin root# ls -ail total 272 2425999 drwxrwxr-x 21 root admin 714 Jun 30 21:59 . 2425998 drwxrwxr-x 9 root admin 306 Sep 4 18:50 .. 2426000 lrwxr-xr-x 1 root admin 8 Jun 30 21:58 2to3 -> 2to3-3.4 2426001 -rwxrwxr-x 1 root admin 140 Feb 23 2015 2to3-3.4 2434068 -rwxrwxr-x 1 root admin 280 Jun 30 21:59 easy_install-3.4 2426002 lrwxr-xr-x 1 root admin 7 Jun 30 21:58 idle3 -> idle3.4 2426003 -rwxrwxr-x 1 root admin 138 Feb 23 2015 idle3.4 2433782 -rwxrwxr-x 1 root admin 252 Jun 30 21:59 pip3 2433783 -rwxrwxr-x 1 root admin 252 Jun 30 21:59 pip3.4 2426004 lrwxr-xr-x 1 root admin 8 Jun 30 21:58 pydoc3 -> pydoc3.4 2426005 -rwxrwxr-x 1 root admin 123 Feb 23 2015 pydoc3.4 2426006 lrwxr-xr-x 1 root admin 9 Jun 30 21:58 python3 -> python3.4 2426007 lrwxr-xr-x 1 root admin 12 Jun 30 21:58 python3-32 -> python3.4-32 2426008 lrwxr-xr-x 1 root admin 16 Jun 30 21:58 python3-config -> python3.4-config 2426009 -rwxrwxr-x 2 root admin 25920 Feb 23 2015 python3.4 2426010 -rwxrwxr-x 1 root admin 13568 Feb 23 2015 python3.4-32 2426011 lrwxr-xr-x 1 root admin 17 Jun 30 21:58 python3.4-config -> python3.4m-config 2426009 -rwxrwxr-x 2 root admin 25920 Feb 23 2015 python3.4m 2426014 -rwxrwxr-x 1 root admin 2081 Feb 23 2015 python3.4m-config 2426015 lrwxr-xr-x 1 root admin 10 Jun 30 21:58 pyvenv -> pyvenv-3.4 2426016 -rwxrwxr-x 1 root admin 275 Feb 23 2015 pyvenv-3.4

I have tried your ln -s python3 python, then I have ; mon-ordi:bin root# ln -s python3 python mon-ordi:bin root# ls -ail total 280 2425999 drwxrwxr-x 22 root admin 748 Sep 4 20:28 . 2425998 drwxrwxr-x 9 root admin 306 Sep 4 18:50 .. 2426000 lrwxr-xr-x 1 root admin 8 Jun 30 21:58 2to3 -> 2to3-3.4 2426001 -rwxrwxr-x 1 root admin 140 Feb 23 2015 2to3-3.4 2434068 -rwxrwxr-x 1 root admin 280 Jun 30 21:59 easy_install-3.4 2426002 lrwxr-xr-x 1 root admin 7 Jun 30 21:58 idle3 -> idle3.4 2426003 -rwxrwxr-x 1 root admin 138 Feb 23 2015 idle3.4 2433782 -rwxrwxr-x 1 root admin 252 Jun 30 21:59 pip3 2433783 -rwxrwxr-x 1 root admin 252 Jun 30 21:59 pip3.4 2426004 lrwxr-xr-x 1 root admin 8 Jun 30 21:58 pydoc3 -> pydoc3.4 2426005 -rwxrwxr-x 1 root admin 123 Feb 23 2015 pydoc3.4 2678978 lrwxr-xr-x 1 root admin 7 Sep 4 20:28 python -> python3 2426006 lrwxr-xr-x 1 root admin 9 Jun 30 21:58 python3 -> python3.4 2426007 lrwxr-xr-x 1 root admin 12 Jun 30 21:58 python3-32 -> python3.4-32 2426008 lrwxr-xr-x 1 root admin 16 Jun 30 21:58 python3-config -> python3.4-config 2426009 -rwxrwxr-x 2 root admin 25920 Feb 23 2015 python3.4 2426010 -rwxrwxr-x 1 root admin 13568 Feb 23 2015 python3.4-32 2426011 lrwxr-xr-x 1 root admin 17 Jun 30 21:58 python3.4-config -> python3.4m-config 2426009 -rwxrwxr-x 2 root admin 25920 Feb 23 2015 python3.4m 2426014 -rwxrwxr-x 1 root admin 2081 Feb 23 2015 python3.4m-config 2426015 lrwxr-xr-x 1 root admin 10 Jun 30 21:58 pyvenv -> pyvenv-3.4 2426016 -rwxrwxr-x 1 root admin 275 Feb 23 2015 pyvenv-3.4 mon-ordi:bin root# python --version Python 2.6.1 Always 2.6.1

Then I have tried ; mon-ordi:bin root# cd /System/Library/Frameworks/Python.framework/Versions/ mon-ordi:Versions root# ls -ail total 0 1041998 drwxr-xr-x 5 root wheel 170 Sep 4 18:48 . 1041997 drwxr-xr-x 7 root wheel 238 Mar 24 2014 .. 1066437 drwxr-xr-x 8 root wheel 272 Mar 24 2014 2.3 1045004 drwxr-xr-x 12 root wheel 408 Mar 24 2014 2.5 1041999 drwxr-xr-x 12 root wheel 408 Mar 24 2014 2.6

mon-ordi:Versions root# ln -s /Library/Frameworks/Python.framework/Versions/3.4/ ./Current mon-ordi:Versions root# ls -ail total 8 1041998 drwxr-xr-x 6 root wheel 204 Sep 4 20:39 . 1041997 drwxr-xr-x 7 root wheel 238 Mar 24 2014 .. 1066437 drwxr-xr-x 8 root wheel 272 Mar 24 2014 2.3 1045004 drwxr-xr-x 12 root wheel 408 Mar 24 2014 2.5 1041999 drwxr-xr-x 12 root wheel 408 Mar 24 2014 2.6 2679207 lrwxr-xr-x 1 root wheel 50 Sep 4 20:39 Current -> /Library/Frameworks/Python.framework/Versions/3.4/ mon-ordi:Versions root# python --version Python 2.6.1 It doesn't work.

jaimeMF commented 9 years ago

I think you also need chmod +x python.

gilles-c commented 9 years ago

To avoid breaking my OS, I have read the documentation for Mac, here an extract ;

4.1. Getting and Installing MacPython Mac OS X 10.8 comes with Python 2.7 pre-installed by Apple. If you wish, you are invited to install the most recent version of Python 3 from the Python website (https://www.python.org). A current “universal binary” build of Python, which runs natively on the Mac’s new Intel and legacy PPC CPU’s, is available there.

What you get after installing is a number of things:

A MacPython 3.4 folder in your Applications folder. In here you find IDLE, the development environment that is a standard part of official Python distributions; PythonLauncher, which handles double-clicking Python scripts from the Finder; and the “Build Applet” tool, which allows you to package Python scripts as standalone applications on your system. A framework /Library/Frameworks/Python.framework, which includes the Python executable and libraries. The installer adds this location to your shell path. To uninstall MacPython, you can simply remove these three things. A symlink to the Python executable is placed in /usr/local/bin/. The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.

End of extract

So the question is ; How to link youtube-dl to a non-system Python ?

jaimeMF commented 9 years ago

I think that as long as you only modify in /Library/Frameworks/Python.framework nothing in your system should break. If /Library/Frameworks/Python.framework/Versions/3.4/bin/ is in your path and /Library/Frameworks/Python.framework/Versions/3.4/bin/python is executable, youtube-dl will use it. Since the issue is not with youtube-dl I'm closing the issue.