python - 我有一个依赖于 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, initialdir=currdir, 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,如果有人也有和我一样,想在此处修复它的链接,只需按照说明进行操作,您将修复它:) URL:module-object-has-no-attribute-audio-fadein