试图在Windows命令提示符中运行我的文件,但找不到Pytube

问题描述 投票:0回答:1

C:\Users\Username\Desktop>YTMP3.py URL

i确保已安装模块,我期望模块正常运行并下载我提供的YouTube URL

使用虚拟环境:

import pytube import os import sys from pathlib import Path from pytube import YouTube destination = 'C:/Desktop/' + str(Path.home()) + '/Downloads' def download_audio(url): yt = YouTube(url) print("Title: ", yt.title) base, ext = os.path.splitext(yt) newfile = base + ".mp3" print("Downloading...") yt.streams.filter(only_audio=True).first().download(output_path=destination, filename=newfile) print("Download complete") if __name__ == "__main__": download_audio(str(sys.argv[1]))

python module youtube command command-prompt
1个回答
0
投票
Githubrepo

中还讨论了另一个问题,我也建议使用

YT-DLP
,因为更新更新,并且错误修复程序更快。
    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.