[Python] iconipy and pyinstaller issue

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to ask you for help with creation of .exe file from python script where I use customtkinter, iconipy libraries.


    After creation of .exe file I finished with this error: [​IMG]

    My python code:

    from PIL import Image
    from customtkinter import CTk, CTkFrame, CTkImage, CTkButton
    from iconipy import IconFactory

    def Create_Icon(Icon_Set: str, Icon_Name: str, Icon_Size: str, Theme_index: int) -> Image:
    Icon_Fact = IconFactory(
    icon_set = Icon_Set,
    icon_size = 40,
    font_size = 30,
    font_color = "#FFFFFF",
    outline_width = 0,
    outline_color = None,
    background_color = None,
    background_radius = 0)
    Icon_PIL = Icon_Fact.asPil(Icon_Name)
    return Icon_PIL

    def Get_CTk_Icon(Icon_Set: str, Icon_Name: str, Icon_Size: str) -> CTkImage:
    Picture = CTkImage(
    light_image = Create_Icon(Icon_Set=Icon_Set, Icon_Name=Icon_Name, Icon_Size=Icon_Size, Theme_index=0),
    dark_image =Create_Icon(Icon_Set=Icon_Set, Icon_Name=Icon_Name, Icon_Size=Icon_Size, Theme_index=1),
    size = (40, 40))
    return Picture

    def Get_Button_Icon(Frame: CTk|CTkFrame, Icon_Set: str, Icon_Name: str, Icon_Size: str, Button_Size: str) -> CTkFrame:
    Frame_Button = CTkButton(
    master = Frame,
    width = 40,
    height = 40,
    corner_radius = 0,
    border_width = 0,
    bg_color = "transparent",
    fg_color = "transparent",
    hover = False,
    anchor = "center",
    text = "")
    CTK_Image = Get_CTk_Icon(Icon_Set=Icon_Set, Icon_Name=Icon_Name, Icon_Size=Icon_Size)
    Frame_Button.configure(image=CTK_Image, text="")
    return Frame_Button

    window = CTk()

    Icon_Theme = Get_Button_Icon(Frame=window, Icon_Set="lucide", Icon_Name="sun-moon", Icon_Size="Header", Button_Size="Picture_Theme")
    Icon_Theme.configure(text="")

    Icon_Theme.pack(side="top", fill="none", expand=False, padx=5, pady=5)

    # run
    window.mainloop()


    I use anaconda for virtual environment where I have only:

    # environment.yml

    name: ENV-Iconipy_Pyinstaller
    channels:
    - defaults
    - https://repo.anaconda.com/pkgs/main
    - https://repo.anaconda.com/pkgs/msys2
    - https://repo.anaconda.com/pkgs/r
    dependencies:
    - bzip2=1.0.8=h2bbff1b_6
    - ca-certificates=2024.12.31=haa95532_0
    - expat=2.6.4=h8ddb27b_0
    - libffi=3.4.4=hd77b12b_1
    - libmpdec=4.0.0=h827c3e9_0
    - openssl=3.0.15=h827c3e9_0
    - pip=24.2=py313haa95532_0
    - python=3.13.2=hadb2040_100_cp313
    - python_abi=3.13=0_cp313
    - setuptools=75.8.0=py313haa95532_0
    - sqlite=3.45.3=h2bbff1b_0
    - tk=8.6.14=h0416ee5_0
    - tzdata=2025a=h04d1e81_0
    - vc=14.42=haa95532_4
    - vs2015_runtime=14.42.34433=he0abc0d_4
    - wheel=0.44.0=py313haa95532_0
    - xz=5.6.4=h4754444_1
    - zlib=1.2.13=h8cc25b3_1
    - pip:
    - altgraph==0.17.4
    - customtkinter==5.2.2
    - darkdetect==0.8.0
    - iconipy==0.3.2
    - packaging==24.2
    - pefile==2023.2.7
    - pillow==11.1.0
    - pyinstaller==6.12.0
    - pyinstaller-hooks-contrib==2025.1
    - pywin32-ctypes==0.2.3
    prefix: C:\Users\CZ011845\AppData\Local\miniconda3\envs\ENV-Iconipy_Pyinstaller


    I installed only python by "conda install python" and then these 3 by pip:

    1. pip install customtkinter
    2. pip install iconipy
    3. pip install pyinstaller

    and I convers the main.py to .exe (in Anaconda):

    1. run: conda activate ENV-Iconipy_Pyinstaller
    2. cd to correct project path
    3. run: pyinstaller --name Test --onedir --windowed main.py
    4. Add path and files into folder "_internal" (because without that there are issues)
    • Path: "_internal/iconipy/assets/lucide/"
    • Empty file1: info.json
    • Empty file2: version.txt

    If I run code in terminal it is correct and I receive this window:

    [​IMG]

    Continue reading...

Compartilhe esta Página