ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
354 stars 35 forks source link

from ctypes.macholib import dyld error。couldn't find this module #534

Open hb-2017 opened 1 month ago

hb-2017 commented 1 month ago

When I was using py2app to package a pyqt5 program, I had already completed the packaging work, but an exception message appeared when starting.

Traceback (most recent call last): File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/boot.py", line 212, in _run() File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/boot.py", line 84, in _run exec(compile(source, path, "exec"), globals(), globals()) File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/main.py", line 8, in from device_manager.scrcpy_adb import ScrcpyADB File "", line 259, in load_module File "device_manager/scrcpy_adb.pyc", line 17, in ImportError: cannot import name 'YOLOv10' from 'ultralytics' (/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/ultralytics/init.py)

When I was checking the boot. py file, I found an error in the 'from ctypes. macholib import dyld' in the 'setupuctypes' file, indicating that the module cannot be found correctly.

image

How should I solve it?

hb-2017 commented 1 month ago

There is still an issue with this file, and the Distribution in the find_ eggs_in_zip method cannot be found. I added pkd_sources earlier to make it run properly.

image image
hb-2017 commented 1 month ago

I found that the reason why I encountered this problem may be that I manually copied the dependency packages in the virtual environment to the lib directory in the resource directory. I am doing this because I am trying to solve the following problem.

/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/MacOS/main ; exit; mark@Mark ~ % /Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/MacOS/main ; exit; requests/init.pyc:86: RequestsDependencyWarning: Unable to find acceptable character detection dependency (chardet or charset_normalizer). init Traceback (most recent call last): File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/boot.py", line 212, in _run() File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/boot.py", line 84, in _run exec(compile(source, path, "exec"), globals(), globals()) File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/main.py", line 8, in from device_manager.scrcpyadb import ScrcpyADB File "<frozen importlib. bootstrap>", line 991, in _find_andload File "<frozen importlib. bootstrap>", line 975, in _find_and_loadunlocked File "<frozen importlib. bootstrap>", line 655, in _loadunlocked File "<frozen importlib. bootstrap>", line 618, in _load_backward_compatible File "", line 259, in load_module File "device_manager/scrcpy_adb.pyc", line 17, in File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/ultralytics/init.py", line 5, in from ultralytics.data.explorer.explorer import Explorer File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/ultralytics/data/init.py", line 3, in from .base import BaseDataset File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/ultralytics/data/base.py", line 17, in from ultralytics.utils import DEFAULT_CFG, LOCAL_RANK, LOGGER, NUM_THREADS, TQDM File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/ultralytics/utils/init.py", line 1025, in SETTINGS = SettingsManager() # initialize settings File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/ultralytics/utils/init.py", line 923, in init from ultralytics.utils.torch_utils import torch_distributed_zero_first File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/ultralytics/utils/torch_utils.py", line 17, in import torchvision File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/torchvision/init.py", line 6, in from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/torchvision/_meta_registrations.py", line 164, in def meta_nms(dets, scores, iou_threshold): File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/torch/library.py", line 467, in inner handle = entry.abstract_impl.register(func_to_register, source) File "/Users/mark/project/dnfm-yolo-tutorial/dist/main.app/Contents/Resources/lib/python3.8/torch/_library/abstract_impl.py", line 30, in register if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"): RuntimeError: operator torchvision::nms does not exist 2024-09-23 19:53:22.476 main[61855:8357347] Launch error 2024-09-23 19:53:22.476 main[61855:8357347] Launch error See the py2app website for debugging launch issues

My code can be packaged normally, but I got this error message when I started it.

I can run it normally in my own local code, and there are no compatibility issues between torchvision and torch versions.

After encountering this error, I also tried to launch main.py directly in the resources directory. I found that it can also be launched, but if I directly launch the. app, it will crash.

image

My project is to display the phone screen through a GUI interface and detect the screen through YOLOV10.

May I ask how I should solve this problem?