Python Version : Python 3.6.7
Operating System : Ubuntu 18.04.1 LTS
uname -a :
Linux ubuntu 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
lsb_release -a :
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
I've tried:
[x] installing spotify-downloader with the pip command provided in README.md ( pip3 install spotdl )
[x] cloning the master branch and running setup.py ( python3 setup.py )
imsky@ubuntu:~$ spotdl --song https://open.spotify.com/track/6USqJZjeIl6slsbStGxEgi --log-level=DEBUG
DEBUG: Fetching metadata for given track URL
DEBUG: Fetching lyrics
DEBUG: {'album': {'album_type': 'album',
'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/7pZH7c4HbKE0ONErpw9cjP'},
'href': 'https://api.spotify.com/v1/artists/7pZH7c4HbKE0ONErpw9cjP',
'id': '7pZH7c4HbKE0ONErpw9cjP',
'name': 'Z谩mb贸 Jimmy',
'type': 'artist',
'uri': 'spotify:artist:7pZH7c4HbKE0ONErpw9cjP'}],
'external_urls': {'spotify': 'https://open.spotify.com/album/48d60Coe3VuNTL3aVK1RlM'},
'href': 'https://api.spotify.com/v1/albums/48d60Coe3VuNTL3aVK1RlM',
'id': '48d60Coe3VuNTL3aVK1RlM',
'images': [{'height': 640,
'url': 'https://i.scdn.co/image/e94f367f5d3ba10c35e80c077202e739decfa30a',
'width': 640},
{'height': 300,
'url': 'https://i.scdn.co/image/c4d4d75624b756169f8ff4c0de1e53828e7ec830',
'width': 300},
{'height': 64,
'url': 'https://i.scdn.co/image/4645eddcb5da1d2f347074c4992815940d7ce1e6',
'width': 64}],
'name': 'Requiem',
'release_date': '2014-11-01',
'release_date_precision': 'day',
'total_tracks': 12,
'type': 'album',
'uri': 'spotify:album:48d60Coe3VuNTL3aVK1RlM'},
'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/7pZH7c4HbKE0ONErpw9cjP'},
'href': 'https://api.spotify.com/v1/artists/7pZH7c4HbKE0ONErpw9cjP',
'id': '7pZH7c4HbKE0ONErpw9cjP',
'name': 'Z谩mb贸 Jimmy',
'type': 'artist',
'uri': 'spotify:artist:7pZH7c4HbKE0ONErpw9cjP'}],
'copyright': '2014 Magneoton',
'disc_number': 1,
'duration': 232.426,
'explicit': False,
'external_ids': {'isrc': 'HUMAG1400155'},
'external_urls': {'spotify': 'https://open.spotify.com/track/6USqJZjeIl6slsbStGxEgi'},
'genre': 'Hungarian Pop',
'href': 'https://api.spotify.com/v1/tracks/6USqJZjeIl6slsbStGxEgi',
'id': '6USqJZjeIl6slsbStGxEgi',
'is_local': False,
'lyrics': None,
'name': '脡jf茅l',
'popularity': 11,
'preview_url': 'https://p.scdn.co/mp3-preview/c0da593b555341d2e7bed3cde4092bceb2dba571?cid=4fe3fecfe5334023a1472516cc99d805',
'publisher': 'Magneoton',
'release_date': '2014-11-01',
'total_tracks': 12,
'track_number': 1,
'type': 'track',
'uri': 'spotify:track:6USqJZjeIl6slsbStGxEgi',
'year': '2014'}
DEBUG: Opening URL: https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=Z%C3%A1mb%C3%B3%20Jimmy%20-%20%C3%89jf%C3%A9l%20lyrics
Traceback (most recent call last):
File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/lib/python3.6/http/client.py", line 1400, in connect
server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 817, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/imsky/.local/bin/spotdl", line 11, in <module>
sys.exit(main())
File "/home/imsky/.local/lib/python3.6/site-packages/spotdl/spotdl.py", line 62, in main
match_args()
File "/home/imsky/.local/lib/python3.6/site-packages/spotdl/spotdl.py", line 27, in match_args
track_dl = downloader.Downloader(raw_song=track)
File "/home/imsky/.local/lib/python3.6/site-packages/spotdl/downloader.py", line 93, in __init__
self.content, self.meta_tags = youtube_tools.match_video_and_metadata(raw_song)
File "/home/imsky/.local/lib/python3.6/site-packages/spotdl/youtube_tools.py", line 58, in match_video_and_metadata
content = go_pafy(track, meta_tags)
File "/home/imsky/.local/lib/python3.6/site-packages/spotdl/youtube_tools.py", line 32, in go_pafy
track_url = generate_youtube_url(raw_song, meta_tags)
File "/home/imsky/.local/lib/python3.6/site-packages/spotdl/youtube_tools.py", line 160, in generate_youtube_url
url = url_fetch.scrape()
File "/home/imsky/.local/lib/python3.6/site-packages/spotdl/youtube_tools.py", line 254, in scrape
item = self._fetch_response(search_url).read()
File "/home/imsky/.local/lib/python3.6/site-packages/spotdl/youtube_tools.py", line 340, in _fetch_response
return urllib.request.urlopen(url)
File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)>
I'm getting the same issue. Does anyone know how to get around it? Thanks!
Are you guys able to reproduce this problem consistently or does it actually download sometimes?
Yes, I can reproduce. I've never been able to download anything. I get that error every time.
Are you guys able to reproduce this problem consistently or does it actually download sometimes?
I can reproduce the problem consistently as well.
@CarterKwon If by any chance you're on OSX, there is a similar issue #125.
As for Linux, I'd like to know whether this code works on python 3 without resulting in an error:
import urllib.request
urllib.request.urlopen("https://google.com/")
and what about trying to fetch the same YouTube search result page that failed (as in log):
import urllib.request
urllib.request.urlopen("https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=Z%C3%A1mb%C3%B3%20Jimmy%20-%20%C3%89jf%C3%A9l%20lyrics")
Also, are you able to open that URL:
https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=Z%C3%A1mb%C3%B3%20Jimmy%20-%20%C3%89jf%C3%A9l%20lyrics
in the web browser?
This might also be of some help:
https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error
I was on OS X. The solution you posted on the other issue fixed my problem. Thank you very much! Been frustrated by that for awhile! Have a good day.
First snippet (URL: https://google.com)
imsky@ubuntu:~/Desktop/Requiem$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.request
>>> urllib.request.urlopen("https://google.com/")
Traceback (most recent call last):
File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/lib/python3.6/http/client.py", line 1400, in connect
server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 817, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): The second snippet (URL: https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=Z%C3%A1mb%C3%B3%20Jimmy%20-%20%C3%89jf%C3%A9l%20lyrics) returned the same output.
File "
File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError:
I can open that url in the web browser ( https://imgur.com/a/lQsLj2N ).
Already tried like everything from the stackoverflow thread. Nothing seemed to work.
I see. It seems to fail for https://google.com/ as well.
Make sure you have ca-certificates package installed:
$ sudo apt install ca-certificates
See if it then works.
What about using python requests to fetch the webpage:
import requests
requests.get("https://google.com")
Package ca-certificates is already installed
imsky@ubuntu:~$ sudo apt install ca-certificates
Reading package lists... Done
Building dependency tree
Reading state information... Done
ca-certificates is already the newest version (20180409).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Using python requests to fetch the webpage:
imsky@ubuntu:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.get("https://google.com")
<Response [200]>
I am not sure what's going on. requests library seems to be working fine while urllib does not.
pip install certifi
/Applications/Python\ 3.6/Install\ Certificates.command
Resolved this problem on MacOs.
On MacOS 11.14 with Python 3.6.4 running the following fixed it for me:
$ pip3 install certifi
$ /Applications/Python\ 3.6/Install\ Certificates.command
On MacOS 11.14 with Python 3.6.4 running the following fixed it for me:
Also in #515 @sephuxeresh suggested something similar. If @Skiuileuf you're still here, could you check whether installing/upgrading certifi python package fixes this?
I had a similar problem on one of my Linux machines. Generating fresh certificates and exporting an environment variable pointing to the certificates directory fixed it:
$ sudo update-ca-certificates --fresh
$ export SSL_CERT_DIR=/etc/ssl/certs
I see. It seems to fail for https://google.com/ as well.
Make sure you have
ca-certificatespackage installed:$ sudo apt install ca-certificatesSee if it then works.
What about using python requests to fetch the webpage:
import requests requests.get("https://google.com")
@ritiek Thanks man. I faced it in docker container (from image ubuntu:18.04 ) and was searching the cloud forever!
When you are using a self signed cert urllib3 version 1.25.3 refuses to ignore the SSL cert
To fix remove urllib3-1.25.3 and install urllib3-1.24.3
pip3 uninstall urllib3
pip3 install urllib3==1.24.3
Tested on Linux MacOS and Window$
I'll close this issue. If someone still has this problem, feel free to respond here or open a new issue!
Was getting same error from Python 3.6.8 on Ubuntu 16.04.6 LTS and @ritiek solution worked for me!
$ sudo update-ca-certificates --fresh
$ export SSL_CERT_DIR=/etc/ssl/certs
I had a similar problem on one of my Linux machines. Generating fresh certificates and exporting an environment variable pointing to the certificates directory fixed it:
$ sudo update-ca-certificates --fresh $ export SSL_CERT_DIR=/etc/ssl/certs
Can I just say thank you for this. I've spent the last 6 hours on this error but this worked.
Thanks the below solution did work for me
$ sudo update-ca-certificates --fresh
$ export SSL_CERT_DIR=/etc/ssl/certs
Most helpful comment
I had a similar problem on one of my Linux machines. Generating fresh certificates and exporting an environment variable pointing to the certificates directory fixed it: