Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I encountered a problem while trying to package a Python program. #273

Open
Lllien1 opened this issue Aug 1, 2024 · 0 comments
Open

I encountered a problem while trying to package a Python program. #273

Lllien1 opened this issue Aug 1, 2024 · 0 comments

Comments

@Lllien1
Copy link

Lllien1 commented Aug 1, 2024

I encountered a problem while trying to package a Python program. The error I got is:
FileNotFoundError: [Errno 2] No such file or directory: 'models\\lab3.pt'
I was trying to package files that include PyQt5 and the Yolov8 model. Whether I used Pyinstaller or cx_Freeze, I faced issues where the .pt file couldn't be found. I also tried compiling the corresponding .spec file, but it didn't include the .py file.

`
block_cipher = None

a = Analysis(
['T.py'],
pathex=['C:\Users\87181\Desktop\Feather_UI'],
binaries=[],
datas=[('C:\Users\87181\Desktop\Feather_UI\ultralytics\cfg\default.yaml', 'ultralytics\cfg'),
('C:\Users\87181\Desktop\Feather_UI\UiProgram\ui_sources.py', 'UiProgram'),
('C:\Users\87181\Desktop\Feather_UI\models\lab3.pt', 'models')],
hiddenimports=['ui_sources_rc'],

hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False

)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='airway_seg',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None )

coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='T',
)

`

but still have error as:

C:\Users\87181\Desktop\Feather_UI\dist\T>airway_seg.exe Traceback (most recent call last): File "T.py", line 449, in <module> File "T.py", line 26, in __init__ File "T.py", line 43, in initialize File "ultralytics\models\yolo\model.py", line 23, in __init__ File "ultralytics\engine\model.py", line 152, in __init__ File "ultralytics\engine\model.py", line 241, in _load File "ultralytics\nn\tasks.py", line 856, in attempt_load_one_weight File "ultralytics\nn\tasks.py", line 782, in torch_safe_load File "torch\serialization.py", line 997, in load File "torch\serialization.py", line 444, in _open_file_like File "torch\serialization.py", line 425, in __init__ FileNotFoundError: [Errno 2] No such file or directory: 'models\\lab3.pt' [13984] Failed to execute script 'T' due to unhandled exception!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant