Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pytube certificate error
#1
Hey,
from pytube import YouTube
url = YouTube("https://www.youtube.com/watch?v=WRfZf43dnj8&ab_channel=TED-Ed")
print(f"video title {url.title}")
Whenever i ran this code snippet, python throws "urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>".
I tried many ways to fix it. But it didnt work.
I tried to update certificates in terminal, install new python version, applications-->python3.13 and double click to install certificate command file. None of them worked.
I use macos and from what I've seen, this problem is mostly experienced by macOS users.
Do you know any solution to solve this? i'm going crazy.
Reply
#2
Pytube is not mantaint anymore use pytubefix or yt-dlp.
If you installed Python from python.org, there’s a script in your Python folder that bootstraps certifi and installs a CA bundle.
In Terminal:
cd "/Applications/Python 3.13"
sudo "./Install Certificates.command"

If you’re using Homebrew Python or the above script didn’t work, do this:
pip3 install --upgrade certifi
Export the SSL_CERT_FILE environment var so urllib uses it:
export SSL_CERT_FILE=$(python3 -c "import certifi; print(certifi.where())")

Tell Python at runtime to use certifi’s bundle
import os
import certifi
os.environ['SSL_CERT_FILE'] = certifi.where()

#from pytube import YouTube
from pytubefix import YouTube

yt = YouTube("https://www.youtube.com/watch?v=WRfZf43dnj8&ab_channel=TED-Ed")
print(f"video title: {yt.title}")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to access Windows Machine or Personal Certificate Store and send to web app seswho 0 3,349 Sep-14-2020, 04:57 PM
Last Post: seswho
  pytube problem mariolopes 2 6,689 Oct-15-2019, 06:49 AM
Last Post: mariolopes
  Local Issuer Certificate aslihanyilmaz 0 4,098 Aug-06-2018, 07:09 AM
Last Post: aslihanyilmaz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020