pytube: HTTP Error 429: Too Many Requests

This piece of code

from pytube import YouTube yt = YouTube('https://www.youtube.com/watch?v=tPEE9ZwTmy0')

Throws this error:

Traceback (most recent call last): File “test.py”, line 2, in <module> yt = YouTube(‘https://www.youtube.com/watch?v=tPEE9ZwTmy0’) File “/home/user/.local/lib/python3.6/site-packages/pytube/main.py”, line 91, in init self.prefetch() File “/home/user/.local/lib/python3.6/site-packages/pytube/main.py”, line 162, in prefetch self.watch_html = request.get(url=self.watch_url) File “/home/user/.local/lib/python3.6/site-packages/pytube/request.py”, line 36, in get return _execute_request(url).read().decode(“utf-8”) File “/home/user/.local/lib/python3.6/site-packages/pytube/request.py”, line 24, in _execute_request return urlopen(request) # nosec 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 532, in open response = meth(req, response) File “/usr/lib/python3.6/urllib/request.py”, line 642, in http_response ‘http’, request, response, code, msg, hdrs) File “/usr/lib/python3.6/urllib/request.py”, line 564, in error result = self._call_chain(*args) 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 756, in http_error_302 return self.parent.open(new, timeout=req.timeout) File “/usr/lib/python3.6/urllib/request.py”, line 532, in open response = meth(req, response) File “/usr/lib/python3.6/urllib/request.py”, line 642, in http_response ‘http’, request, response, code, msg, hdrs) File “/usr/lib/python3.6/urllib/request.py”, line 570, in error return self._call_chain(*args) 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 650, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 429: Too Many Requests

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 20 (2 by maintainers)

Most upvoted comments

I have the same question, did you solve it?

Is there any solution for this please, the issue is still there as at 9th July 2020. since March 26, there hasnt been any clear solution. Please if you know how to prevent Youtube from Banning IP Address, kindly let us know.

Same Problem.

Hi @arslandogar , @infinity-plus , @shihyuuuuuuu @shocklet @godfrednanaowusu

Am closing issue as it has been quite a while – feel free to reopen if this issue still exists 😄

Thanks

I have the same problem so I tried @AlaaProg’s solution but now I get the following error. Can someone help me? image

I have the same BrowserCookieError, could you please tell me how you solved this problem? Thank you.

@ZD511 @AliAkhtari78 @bigsandip

Me and @arslandogar were discussing this issue here, I was not able to replicate the behaviour on my machine, and was not able to solve it.

Just a few questions that would be helpful if you could answer:

  1. Did this ever work for you? If it did work for you previously, when did it stop working?
  2. Does this issue happen 100% of the time for you when trying to use it?
  3. Does youtube-dl work for you?
  4. Is YouTube blocked in your country?
  5. Have you tried using a VPN?
  6. What version of Python and what version of pytube are you running?
  7. What operating system are you running?

I would recommend you all uninstall pytube completely, make sure it is uninstalled, then install pytube3 and try again. It is best actually if you can create a virtual environment and run

pip install pytube3

inside that virtual environment. I hope I can get this working for all of you.