Skip to content

Version 4.52.3 leads to error after bundling with pyinstaller #38402

Open
@HiokKuek

Description

@HiokKuek

System Info

The new versioning induces the following error when trying to bundle a python script that contains imports from the transformers library.

File "functions\classify.py", line 1, in <module>
    from transformers import DistilBertTokenizer, DistilBertForSequenceClassification
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1412, in _handle_fromlist
  File "transformers\utils\import_utils.py", line 2045, in __getattr__
  File "transformers\utils\import_utils.py", line 2075, in _get_module
  File "transformers\utils\import_utils.py", line 2073, in _get_module
  File "importlib\__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 450, in exec_module
  File "transformers\models\__init__.py", line 341, in <module>
  File "transformers\utils\import_utils.py", line 2594, in define_import_structure
  File "transformers\utils\import_utils.py", line 2305, in create_import_structure_from_path
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\ernest\\Desktop\\URL-Extractor-Extension\\native_messaging_genai\\dist\\main\\_internal\\transformers\\models\\__init__.pyc'
[PYI-9628:ERROR] Failed to execute script 'main' due to unhandled exception!

Error goes away after downgrading to v4.51.3

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

  1. Python script that uses transformers, in my case from transformers import AutoTokenizer, AutoModelForSequenceClassification
  2. bundle with pyinstall
  3. run the .exe file

Expected behavior

The things you intend to do with your python script (native host application in my case).

The recent update made it such that your application will crash wth the error as described above when you try and run the .exe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions