📦 Build Recipe: YouTube Downloader Standalone on Linux Mint

  1. Install prerequisites (system-wide, once only)

    sudo apt-get update
    sudo apt-get install -y python3-venv python3-pip
  2. Set up a clean build environment

    python3 -m venv buildenv
    source buildenv/bin/activate
    pip install --upgrade pip setuptools wheel
    pip install pyinstaller pillow
  3. Save the .spec file

    Save this as youtube-downloader.spec in the same folder as youtube-downloader.py:

    # youtube-downloader.spec
    from PyInstaller.utils.hooks import collect_submodules
    import os, PIL
    
    pillow_path = os.path.dirname(PIL.__file__)
    datas = [(os.path.join(pillow_path, "..", "PIL"), "PIL")]
    
    a = Analysis(
        ['youtube-downloader.py'],
        pathex=[],
        binaries=[],
        datas=datas,
        hiddenimports=collect_submodules("PIL"),
        hookspath=[],
        hooksconfig={},
        runtime_hooks=[],
        excludes=[],
        noarchive=False,
    )
    
    # Exclude PyInstaller’s bundled zlib to avoid relocation errors
    a.binaries = [x for x in a.binaries if 'libz.so' not in x[0]]
    
    pyz = PYZ(a.pure)
    
    exe = EXE(
        pyz,
        a.scripts,
        a.binaries,
        a.zipfiles,
        a.datas,
        [],
        name='youtube-downloader',
        debug=False,
        bootloader_ignore_signals=False,
        strip=False,
        upx=True,
        console=False,
        icon='/usr/share/icons/hicolor/256x256/apps/ytdlp.png'
    )
  4. Build the standalone

    pyinstaller youtube-downloader.spec
  5. Find your binary

    The built executable will be here:

    dist/youtube-downloader

    Copy it wherever you like (e.g. /usr/local/bin/ if you want it system-wide).

✅ Notes

  • This recipe fixes relocation errors (libz.so.1) on Mint.
  • Pillow is bundled so your Astral/Lunar background GIFs work.
  • You can rebuild anytime by just running:
    source buildenv/bin/activate
    pyinstaller youtube-downloader.spec

 

By admin