pytube import Youtube: missing package

Viewed 68

my Code:

from pytube import Youtube
from sys import argv


link = input("put the link input:")
yt = Youtube[link]

print("Title: ", yt.Title)

yd = yt.streams.get_highest_resolution()

yd.download(r'C:\Users\adam6\OneDrive\Desktop\video')

ERROR:

ImportError: cannot import name 'Youtube' from 'pytube' (C:\Users\adam\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube_init_.py)


  1. I checked and init.py > is there at C:\Users\adam\AppData\Local\Programs\Python\Python310\lib\site-packages\pytube
PS C:\Users\adam> pip install pytube3 --upgrade                                                Requirement already satisfied: pytube3 in c:\users\adam\appdata\local\programs\python\python310\lib\site-packages (9.6.4)
Requirement already satisfied: typing-extensions in c:\users\adam\appdata\local\programs\python\python310\lib\site-packages (from pytube3) (4.3.0)
  1. using Visual Studio Code to run it.
PS C:\Users\adam\OneDrive\Desktop\study\python> python --version
Python 3.10.6
PS C:\Users\adam\OneDrive\Desktop\study\python>

A. yes i needed to change it to YouTube

ran into another error:

I build mine from start to bottom, and ran into to another issue, here are the code and steps. hope this helps if someone is building there

Code:

from pytube import YouTube from sys import argv

link = argv[1] yt = YouTube(link)

yd = yt.streams.get_highest_resolution()

yd.download(r'C:/Users/adam/OneDrive/Desktop/video')

got error:

urllib.error.HTTPError: HTTP Error 410: Gone

STEPS:

python -m pip install --upgrade pytube

python3 -m pip install git+https://github.com/pytube/pytube

Ran as ADMIN.

worked fine!

1 Answers

I think there is a typo in from pytube import Youtube.

Youtube should be YouTube. So you can try:

from pytube import YouTube

and :

yt = YouTube(link)

reference : https://pytube.io/en/latest/

Related