I used pyinstaller to make an exe file for my project. When I run the exe file after its done I get the following FileNotFoundError:
Failed to execute script 'main' due to unhandles exception:
[Errno 2] No such file or directory:
'C:\\Users\\p-IN-CHE7-ptsintern\\AppData\\Local\\Temp\\_MEI96922\\ultralytics\\cfg\\default.yaml'
Traceback (most recent call last):
File "main.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "src\app\frontend\main_ui.py", line 6, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "src\app\backend\oscilloscope_report_maker.py", line 15, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "src\app\backend\yolov8\predict.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "ultralytics\__init__.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "ultralytics\models\__init__.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "ultralytics\models\rtdetr\__init__.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "ultralytics\models\rtdetr\model.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "ultralytics\engine\model.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "ultralytics\cfg\__init__.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "ultralytics\utils\__init__.py", line 384, in <module>
File "ultralytics\utils\__init__.py", line 354, in yaml_load
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\p-IN-CHE7-ptsintern\\AppData\\Local\\Temp\\_MEI96922\\ultralytics\\cfg\\default.yaml'
I even tried updating my ultralytics package using pip before making the exe file. Still it returns this error.
It would be appreciated if someone would help me in this matter.
Thank you.
I found a fix for this. So i went to the ultralytics package folder and I had to change a code from
__init.py__
under utils (...\ultralytics\utils\__init__.py
).I changed the code on line 35 from:
DEFAULT_CFG_PATH = ROOT / 'cfg/default.yaml'
to
DEFAULT_CFG_PATH = 'Absolute path to cfg/default.yaml'
The cfg/default.yaml is under the ultralytics package folder itself.
I think it might be better to leave the DEFAULT_CFG_PATH empty, but I haven't tried it.