-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
🐛 Description
I'm building a macOS .app using py2app, which includes torchvision (required by easyocr). Although the app builds without error and includes the torchvision/_C.so binary, I get a runtime error stating that the torchvision::nms operator is missing.
💥 Runtime Error
RuntimeError: operator torchvision::nms does not exist📁 Bundle Structure Verified
The .so file exists inside the final app bundle:
ls -a dist/main.app/Contents/Resources/lib/python3.12/torchvision. __pycache__ extension.py transforms
.. _internally_replaced_utils.py image.so tv_tensors
.dylibs _meta_registrations.py io utils.py
_C.so _utils.py models version.py
__init__.py datasets ops
torchvision.ops and other modules are also included. Still, torchvision::nms is unavailable at runtime, indicating the C++ extension may not be registering its operators correctly within the app environment.
⚙️ Environment Details
| Component | Version |
|---|---|
| macOS | 15.1 (24B2083) |
| Machine | Mac mini (Apple M4, 16 GB RAM) |
| Python | 3.12.6 |
| torch | 2.2.1 |
| torchvision | 0.17.1 |
| py2app | 0.28.8 |
| easyocr | 1.7.2 |
Confirmed using:
sw_vers && sysctl -n machdep.cpu.brand_stringProductName: macOS
ProductVersion: 15.1
BuildVersion: 24B2083
Apple M4
🔍 What I've Tried
- Ensured
torchvision._C.sois in the bundle - Included
torchvision,torchvision.ops, andtorchvision._Cinpackagesandincludesinsetup.py - Also explicitly imported the above modules in
main.py - No errors about missing files or libraries — just the unregistered operator at runtime
Thanks in advance for any guidance. I had attached my setup.py file below. If anything else required, I'll happy to provide.
setup.py
from setuptools import setup
import glob
import sys
sys.setrecursionlimit(10000)
import os
from utils import get_tessbin_path, get_tessdata_path
# Check if the external binary and tessdata directories exist
if not os.path.exists(get_tessbin_path()):
raise FileNotFoundError("The external binary directory 'external_bin/TESS_BIN' does not exist.\nTry to install tesseract as described in the README.md file.")
TESS_BIN = get_tessbin_path()
TESS_DATA = get_tessdata_path()
print("TESS_BIN:", TESS_BIN)
print("TESS_DATA:", TESS_DATA)
setup(
app=["main.py"],
setup_requires=["py2app"],
options={
'py2app': {
'excludes': ['rubicon'],
'iconfile': 'icons/icon.icns',
'plist': {
'CFBundleIconFile': 'icons/icon.icns',
'CFBundleName': 'main'
},
'packages': ['paddleocr', 'easyocr', 'pytesseract', 'torch', 'torchvision'],
'includes': ['shapely._geos'],
'site_packages': True,
}
},
data_files=[
('models/tesseract', [TESS_BIN, TESS_DATA]),
("icons", [os.path.join("icons", x) for x in os.listdir("icons")]),
("models", [os.path.join("models", x) for x in os.listdir("models")]),
],
install_requires=[
'paddleocr',
'pandas',
'opencv-python',
'numpy<2',
'Pillow',
'requests',
'openpyxl',
'ttkbootstrap',
'pytesseract',
'easyocr',
'torch==2.2.1',
'torchvision',
'dotenv',
'pyautogui',
'py2app',
'jaraco.text',
]
)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels