[Python] I am stuck with PyInstaller Error ModuleNotFound

Discussão em 'Python' iniciado por Stack, Julho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I am loosing my mind on trying to build an .exe file with pyinstaller, since even thou I made sure to pip install the module and add it to hidden import it still cannot find it.

    To be more specific here are my imports on the file that causes the problem

    from sortedcontainers import SortedList
    from twitchio.ext import commands
    from queue import Empty
    from PIL import Image
    import datetime as dt
    import aiohttp
    import requests
    import asyncio
    import json
    import io
    import os
    import twitchio.errors


    Now, I get the error with 'sortedcontainers', but if I move it down then the same error will come for 'twitchio', making it not specific module dependent

    This is the error I get when running the built .exe file

    File "main.py", line 1, in <module>

    File "PyInstaller\loader\pyimod02_importers.py", line 457, in exec_module

    File "twitch_bot.py", line 1, in <module>

    ModuleNotFoundError: No module named 'sortedcontainers'


    And these is my requirements.txt if useful for context

    customtkinter~=5.2.2
    aiohttp~=3.12.13
    requests~=2.32.4
    twitchio~=2.10.0
    sortedcontainers~=2.4.0
    pillow~=11.3.0


    As for bash commands, I tried few, here are some:

    pyinstaller --clean --noconsole -F --name "Twitch Chatter Catcher" main.py

    pyinstaller --clean --noconsole -F --name "Twitch Chatter Catcher" main.py --hidden-import=sortedcontainers --hidden-import=twitchio

    pyinstaller --clean --noconsole -F --name "Twitch Chatter Catcher" main.py --hidden-import sortedcontainers

    pyinstaller --noconsole -F --name "Twitch Chatter Catcher" main.py


    And my code is structured as follows:

    Project/
    ├─ requirements.txt/
    ├─ setup/
    │ ├─ setup_gui.py
    ├─ themes/
    │ ├─ purple_twitch.json
    ├─ gui.py
    ├─ main.py
    ├─ README.md
    ├─ twitch_bot.py


    Anyone got a tip?

    Edit: Added screenshot of error as shown

    enter image description here

    And the same Traceback in text:

    Traceback (most recent call last):
    File "main.py", line 1, in <module>
    File "PyInstaller\loader\pyimod02_importers.py", line 457, in exec_module
    File "twitch_bot.py", line 1, in <module>
    ModuleNotFoundError: No module named 'sortedcontainers'

    Continue reading...

Compartilhe esta Página