这是我正在尝试运行的Python程序。
import pytube
pytube.YouTube('https://www.youtube.com/watch?v=qxhMUbpm_XI').streams.first().download()
yt = pytube.YouTube('https://www.youtube.com/watch?v=qxhMUbpm_XI')
yt.streams
....filter(progressive=True, file_extension='mp4')
....order_by('resolution')
....desc()
....first()
....download()
当我尝试运行它时,我得到这个:
PS F:\new Programming\python> pip install pytube
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pytube in c:\users\ahmed\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (15.0.0)
PS F:\new Programming\python> python download_from_youtube
C:\Users\ahmed\AppData\Local\Microsoft\WindowsApps\python.exe: can't open file 'F:\\new Programming\\python\\download_from_youtube': [Errno 2] No such file or directory
PS F:\new Programming\python>
每次尝试运行 python 代码时都会出现此错误...有人可以帮忙吗?
您必须添加
.py
扩展名。像 python download_from_youtube.py
而不是 python download_from_youtube
一样运行它。