Search code examples
pythonpytube

can't retrieve youtube title using yt.title from pytube library


After running this:

from pytube import YouTube

yt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')
print(yt.title)

python version 3.11.3

I receive this error:

raceback (most recent call last):
  File "C:\Users\jay\PycharmProjects\pythonProject\youtube.py", line 4, in <module>
    print(yt.title)
          ^^^^^^^^
  File "C:\Users\jay\PycharmProjects\pythonProject\venv\Lib\site-packages\pytube\__main__.py", line 346, in title
    raise exceptions.PytubeError(
pytube.exceptions.PytubeError: Exception while accessing title of https://youtube.com/watch?v=2lAe1cqCOXo.

I was expecting to receive a title


Solution

  • I started using yt-dlp plugin.