【问题标题】:Pyinstaller error "ModuleNotFoundError:" after converting python file to .exe将 python 文件转换为 .exe 后,Pyinstaller 错误 \"ModuleNotFoundError:\"
【发布时间】:2023-01-18 17:24:14
【问题描述】:

我想将我的 python 文件转换为可执行文件 (.exe),但是当我在转换文件后尝试运行 .exe 时,它​​给了我这个错误:

由于未处理的异常,无法执行脚本“main”:没有名为“moviepy”的模块 回溯(最后一次通话): 文件“main.py”,第 4 行,位于 ModuleNotFoundError:没有名为“moviepy”的模块

请注意我已经在终端上安装了 moviepy。

from tkinter import *
from tkinter import filedialog
from moviepy import *
from moviepy.editor import VideoFileClip
from pytube import YouTube

import shutil

screen = Tk()
title = screen.title("Youtube Downloader")
canvas = Canvas(screen, width=500, height=500)
canvas.pack()

# Functins
def select_path():
    path = filedialog.askdirectory()
    path_label.config(text=path)

def download_video():
    #get user path
    get_link = link_field.get()
    #get selected path
    user_path = path_label.cget("text")
    screen.title('Downloading...Please Wait...')
    #Download Video
    mp4_video = YouTube(get_link).streams.get_highest_resolution().download()
    vid_clip = VideoFileClip(mp4_video)
    vid_clip.close()
    #move file to selected directory
    shutil.move(mp4_video, user_path)
    screen.title('Download Completed!')

# Logo
logoimg = PhotoImage(file="images/download.png")

# Resize Logo
logoimg = logoimg.subsample(2, 2)
canvas.create_image(250, 80, image=logoimg)

# Link Field
link_field = Entry(screen, width=50)
link_label = Label(screen, text="Paste Download Link: ", font=("Sans Serif", 13))

# Link Field Box
canvas.create_window(250, 170, window=link_label)
canvas.create_window(250, 210, window=link_field)

# Select Path
path_label = Label(screen, text="Select Local Path: ", font=("Sans Serif", 13))
select_button = Button(screen, text="Select", command=select_path)    # Select Button

# Select Path Box
canvas.create_window(250, 270, window=path_label)
canvas.create_window(250, 320, window=select_button)

# Download Button
download_bttn = Button(screen, text="Download Video", font=("Sans Serif", 12),  command=download_video)
canvas.create_window(250, 400, window=download_bttn)

screen.mainloop()

我在终端“pip install moviepy”上安装了 moviepy,我还尝试在 PyCharm 的 python 解释器上手动安装。

【问题讨论】:

    标签: python-3.x youtube pyinstaller exe moviepy


    【解决方案1】:

    这是因为有些文件不会自动从 moviepy 应用程序中收集。

    您可以使用 --collect-all 命令行标志来指示您需要与可执行文件捆绑在一起的特定包的全部内容。

    所以它看起来像这样:

    pyinstaller -F --collect-all moviepy myscriptname.py
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-05
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 2016-08-03
      • 1970-01-01
      • 1970-01-01
      • 2020-07-15
      相关资源
      最近更新 更多