pythoniconscx-freezerapidfuzz

cx_freeze: no module named rapidfuzz.distance.metrics_py


I am trying to add an icon to my python app. I have added it to my config in setup.py and drew the icon. However, there was no icon on the executable after I compiled it. I tried to run the program, and it resulted in an error ending with ModuleNotFoundError: No module named "rapidfuzz.distance.metrics_py":

error_image

The error was captured using a screen record tool fyi.

I tried installing the rapidfuzz module on its own, and I was told that it was already installed.

I tried updating rapidfuzz and then recompiling my code: same error.

I searched the web and did not find any evidence of metrics_py (or metrics.py) even existing. Correct me if I searched too bad please.

I tried installing rapidfuzz.distance.metrics_py (and .py) using pip. No matching contribution was found.

My setup.py file:

import sys
from cx_Freeze import setup, Executable

build_exe_options = {"packages": ["os", "random", "time", "sqlite3", "Bio"], "excludes": []}

base = None
if sys.platform == "win32":
    base = "win32GUI"

setup(name="Helix",
      version="0.3",
      description="Console",
      options={"Genetics": build_exe_options},
      executables=[
          Executable("Helix.py",
                     base=base,
                     copyright="No official registered copyright",
                     trademarks="No official registered trademark",
                     icon="icon.ico")])

The icon file does exist in the directory as the PyCharm project (and in the executable directory). My executable ran perfectly fine before adding the icon.

I am using 2021 PyCharm community edition, python 3.10 miniconda interpreter and miniconda environment.

I would really use help.

Thanks in advance.


Solution

  • RapidFuzz dynamically dispatches to different implementations of algorithms for the following purposes:

    Historically, this was done using importlib. However, tools like cx-Freeze cannot interpret this mechanism. As a result, it was necessary to manually specify the missing includes. Starting from RapidFuzz version 3.12.0, I now generate these files in a format that's easier for such tools to understand. Therefore, upgrading the library should resolve the issue automatically.