我有一个依赖于 pytube 的代码,但是当我尝试转换为 exe 时它不起作用

问题描述

我一直在编写用于在 python 上下载视频的代码,它运行良好,但是当我尝试为另一台计算机制作 .exe 时,它​​从来没有像我将其转换为 pyinstaller a.py 那样强大,我'我也使用 python 3.9 我只是想在 exe 中使用 pytube 我见过只有一小部分人有同样的问题,但我看到的那个人犯了一个错误,把 pyinstaller -noconsole python.py 放在那里,但我没有把它放在那里,我仍然不明白是什么问题有人可以帮我吗?

from pytube import YouTube
import os,shutil
import subprocess
import tkinter
from tkinter import filedialog as tkFileDialog
import moviepy
import sys
from moviepy.editor import VideoFileClip
root = tkinter.Tk()

root.withdraw()
currdir = os.getcwd()

def get_mp3():
    qq=int(input("how many videos would you download: "))
    output = input("What format would you like it in (mp4/mp3)?: ")
    for i in range(0,qq):
        if output == "mp4":
            url = input("Enter a YouTube link: ")
            print("Chose a location")
            location = tkFileDialog.askdirectory(parent=root,initialdir=currdir,title='Please select a directory to download the video')
            yt = YouTube(url)
            print("Title: ",yt.title)
            print("Number of views: ",yt.views)
            print("Length of video: ",yt.length)
            
            print("rating of video: ",yt.rating)
            ys = yt.streams.get_highest_resolution()    
            print("Downloading...")
            ys.download(location)
        
            print("Complete")
            if i == qq:
                sys.exit(0)
            
    if output == "mp3":
        for x in range(0,qq):
            url = input("Enter a YouTube link: ")
        
            print("Chose a location")
            location = tkFileDialog.askdirectory(parent=root,title='Please select a directory to download the video')
            print(location)
        
            mp4 = YouTube(url).streams.get_highest_resolution().download()
            mp3 = mp4.split(".mp4",1)[0] + f".{output}"

            video_clip = VideoFileClip(mp4)
            audio_clip = video_clip.audio
            audio_clip.write_audiofile(mp3)

            audio_clip.close()
            video_clip.close()

            os.remove(mp4)
            shutil.move(mp3,location)  # Replace this with your own output directory


get_mp3()

解决方法

实际上一切都结束了,我不得不因为它改变了给我错误的实际事物的所有int,所以它与pytube无关关于movie.py,如果有人也和我有同样的事情并想在这里修复它的链接,然后按照说明进行操作,您将修复它:) 网址:module-object-has-no-attribute-audio-fadein

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...