3

When i try to run my script, which is just those two lines:

from pytube import YouTube
YouTube('http://youtube.com/watch?v=9bZkp7q19f0').streams.first().download()

i get the error:

ImportError: cannot import name 'YouTube' from 'pytube' (unknown location)

ive used the following documentation to install pytube: https://github.com/NFicano/pytube

but since i am using python3.8 i installed pytube3 using:

pip3 install pytube3

instead of:

pip install pytube

which does not throw errors from the module.

When double check if there is a "pytube" module directory in:

C:\Users\User\AppData\Local\Programs\Python\Python38\Lib\site-packages if found the directory: "\pytube" inside of it

when i use: pip install pytube3 i get the output:

Requirement already satisfied: pytube3 in c:\users\User\appdata\local\programs\python\python38\lib\site-packages (9.6.4)
Requirement already satisfied: typing-extensions in c:\users\User\appdata\local\programs\python\python38\lib\site-packages (from pytube3) (3.7.4.2)
  • FYI - It appears that `pytube3` is a fork of `pytube` and has a CLI (Command Line Interface) https://github.com/get-pytube/pytube3 – JayRizzo Dec 31 '22 at 18:50
  • Where the https://github.com/pytube/pytube Does not have the CLI – JayRizzo Dec 31 '22 at 18:51
  • FWIW I just use the basic `pytube` and doing a `reinstall` fixed my issue for my use case. https://github.com/JayRizzo/JayRizzoTools/blob/master/pyTubeGUI.py – JayRizzo Dec 31 '22 at 18:54

2 Answers2

4

pip uninstall pytube3 pip install pytube3 Step 2 returns the filepath where pytube3 was installed. go to the folder that was returned, open "pytube/", and clear the contents of the "pycache" folder, which has all the ".pyc" files. These are not important and can be regenerated by the package whenever it is loaded.

If all of that doesn't work try doing the following pip install pytube3 --upgrade

Ahmed Khaled
  • 308
  • 3
  • 14
1

use this:- it works for me after upgrade your pytube

pip install pytube3 --upgrade

import pytube

myVideo = pytube.YouTube('youtube's video url')

Amit Bahadur
  • 246
  • 3
  • 7