Can't compile project to .exe, that uses transformers (Windows 10)

I’m using simple script, which use transformer library. Like loading model definition and tokenizer from files, text-to-text generation task, and some UI, and it’s working while launched from python-file. But same script can’t bee compiled in .exe, something always will went wrong. I tried to use different versions of packages, python, compilers (mostly PyInstaller), nothing seems to work.

Main issue is this exception:
"AttributeError: ‘NoneType’ object has no attribute ‘flush’ "
Which means some trouble in logger (full down below). Tried use this in script (not helped):
logger = logging.getLogger(‘transformers’)
logger.disabled = False
logger.setLevel(logging.NOTSET)

Tried to use console only, and get this instead:


And no matter have I installed tqdm or not. Put simple progress bar in beginning from last version tqdm, same output.

I have no idea what else can I do in this situation. If You find a solution to this, please, describe each step in as much detail as possible.
Full output:

Traceback (most recent call last):
File “main.py”, line 16, in
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 499, in exec_module
File “lang_model.py”, line 8, in
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 499, in exec_module
File "transformers_init
.py", line 30, in
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 499, in exec_module
File “transformers\dependency_versions_check.py”, line 36, in
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 499, in exec_module
File “transformers\file_utils.py”, line 60, in
File “transformers\utils\logging.py”, line 123, in get_logger
File “transformers\utils\logging.py”, line 86, in _configure_library_root_logger
AttributeError: ‘NoneType’ object has no attribute ‘flush’

1 Like

Hey, i’m having the exact same issue and i’m stuck on it. Have you fixe this issue ?

No. Haven’t touched this project since this post

You have to add the metadata of tqdm, transformer have about 10 library to add like this :
Pyinstaller --noconfirm main.py --collect-data torch --copy-metadata torch -copy-metadata tqdm -copy-metadata regex …