title: How to include non-python modules in python scripts while converting it to exe?
body: <p>As far as I know, ffmpeg is not a built-in python module but it comes with moviepy module? (I'm not sure), so in order to use it, we need to manually install it. However, I installed it on my computer and my program works perfectly, but then I thought about converting my program to an executable file so that I can show it to my friends, once I did that the program lost functionality, and it turned out that whomever I send the program to should have ffmpeg on their computers! How am I going to fix this?</p>
  <p><strong>Note</strong>: on the os.environ line, I'm giving it the path where the ffmpeg exe file is in it.</p>
  <p><strong>Note</strong>: I used both pyinstaller and cx_freeze but none worked.</p>
  <p>The program is a GUI Youtube mp3 downloader (you can use it if you have time), it downloads a video.mp4 first, converts the mp4 to mp3, and then deletes the mp4.</p>
  <p>I appreciate any help, I have been looking for solutions from all over the internet, nothing helped so far, any suggestions are welcomed, or if there is any other way I can download MP3s from a youtube video? Thanks in advance.</p>
  <p>Here's the code:</p>
  <pre><code>from tkinter import *
  from tkinter import filedialog
  from pytube import YouTube
  from tkinter import messagebox
  import os
  os.environ[&quot;IMAGEIO_FFMPEG_EXE&quot;] = r&quot;C:\Users\Totenkopf\Downloads\test\ffmpeg&quot;
  from moviepy.video.io.VideoFileClip import VideoFileClip
  
  def space():
      space = Label(text=&quot;&quot;, bg=&quot;black&quot;)
      space.grid()
  
  Folder_Name = &quot;&quot;
  
  def open_location():
      global Folder_Name
      Folder_Name = filedialog.askdirectory()
      os.chdir(Folder_Name)
      if len(Folder_Name) &gt; 1:
          path_url.config(text=Folder_Name, fg=&quot;green&quot;)
  
      else:
          messagebox.showwarning(title=&quot;oops&quot;, message=&quot;No path given!&quot;)
          path_url.config(text=&quot;Please specify a folder!&quot;, fg=&quot;red&quot;)
      return
  
  def convert_to_mp3():
      if len(url_box.get()) &gt; 1 and &quot;youtube.com&quot; in url_box.get():
          url_error.config(text=&quot;&quot;)
          root.update()
          if len(Folder_Name) &gt; 1:
              yt = YouTube(url_box.get())
              yt.streams.get_highest_resolution().download(Folder_Name)
              music = yt.streams.first()
              default_filename = music.default_filename
              new_filename = default_filename.split(&quot;.&quot;)[0]
              mp4 = Folder_Name + fr'/{new_filename}.mp4'
              mp3 = Folder_Name + fr'/{new_filename}.mp3'
              videoclip = VideoFileClip(mp4)
              audioclip = videoclip.audio
              audioclip.write_audiofile(mp3)
              audioclip.close()
              videoclip.close()
              os.system(f' del &quot;{new_filename}.mp4&quot;')
              progress_bar.config(text=&quot;Downloaded successfully&quot;, fg=&quot;green&quot;)
          else:
              messagebox.showwarning(title=&quot;oops&quot;, message=&quot;No path given!&quot;)
              path_url.config(text=&quot;Please specify a folder!&quot;, fg=&quot;red&quot;)
  
      else:
          messagebox.showwarning(title=&quot;oops&quot;, message=&quot;Wrong URL!&quot;)
          url_error.config(text=&quot;Try again!&quot;, fg=&quot;red&quot;)
  
  
  
  #----------------------------- GUI -------------------------------#
  
  root = Tk()
  root.title(&quot;Youtube Downloader&quot;)
  root.geometry(&quot;350x400&quot;)
  root.columnconfigure(0, weight=1)
  root.config(bg=&quot;black&quot;)
  
  space()
  space()
  space()
  space()
  space()
  
  url_label = Label(root, text=&quot;Enter video / playlist URL&quot;, bg=&quot;black&quot;, fg=&quot;white&quot;, font=(&quot;jost&quot;, 9, &quot;bold&quot;))
  url_label.grid()
  
  EntryVar = StringVar()
  url_box = Entry(root, width=50, textvariable=EntryVar)
  url_box.grid()
  
  url_error = Label(root, text=&quot;&quot;, fg=&quot;red&quot;, bg=&quot;black&quot;, font=(&quot;jost&quot;, 9, &quot;bold&quot;))
  url_error.grid()
  
  space()
  
  path_label = Label(root, text=&quot;Save the video file&quot;, bg=&quot;black&quot;, fg=&quot;white&quot;, font=(&quot;jost&quot;, 9, &quot;bold&quot;))
  path_label.grid()
  
  path_btn = Button(root, width=11, height=2, bg=&quot;#CC1B25&quot;, fg=&quot;white&quot;, text=&quot;Choose Path&quot;, command=open_location)
  path_btn.grid()
  
  path_url = Label(root, text=&quot;&quot;, fg=&quot;red&quot;, bg=&quot;black&quot;, font=(&quot;jost&quot;, 9, &quot;bold&quot;))
  path_url.grid()
  
  space()
  
  mp3_btn = Button(width=23, height=1, bg=&quot;black&quot;, fg=&quot;white&quot;, text=&quot; Download MP3&quot;,
                   font=(&quot;jost&quot;, 11, &quot;bold&quot;), command=convert_to_mp3)
  mp3_btn.grid()
  
  space()
  
  progress_bar = Label(root, text=&quot;&quot;, bg=&quot;black&quot;, fg=&quot;white&quot;, font=(&quot;jost&quot;, 11, &quot;bold&quot;))
  progress_bar.grid()
  
  space()
  
  
  root.mainloop()
  </code></pre>