cyril
cyril

Reputation: 3005

py2app: No module named cv2.config-3.9

I created an cross-platform app using PyQt 5.15.4 and I'm now trying to compile it in order to distribute it to my testers as a standalone application. These are the packages my application relies on:

import pandas as pd 
import cv2
from cv2 import VideoCapture, imwrite, resize, CAP_PROP_FPS, CAP_PROP_FRAME_COUNT, INTER_AREA

Running the app.py file runs without as a hitch but as soon as I try to use py2app, I get the following error:

/usr/local/lib/python3.9/site-packages/modulegraph/find_modules.py:249: UserWarning: No package named opencv-python
  warn("No package named %s" % f)
*** using recipe: PIL *** {'prescripts': ['py2app.recipes.PIL.prescript', <_io.StringIO object at 0x105a57310>], 'include': 'PIL.JpegPresets', 'flatpackages': ['/usr/local/lib/python3.9/site-packages/PIL']}
*** using recipe: automissing *** {'expected_missing_imports': {'nt', '_winapi', 'netbios', 'sys.getwindowsversion', 'winreg', 'win32wnet', '_frozen_importlib_external'}}
*** using recipe: autopackages *** {'packages': ['numpy']}
CTYPES USERS [SourceModule('ctypes._endian', '/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/_endian.py'), Package('test.support', '/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/test/support/__init__.py', ['/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/test/support']), SourceModule('ctypes.wintypes', '/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/wintypes.py'), Package('ctypes.macholib', '/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/macholib/__init__.py', ['/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/macholib']), SourceModule('ctypes._aix', '/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/_aix.py'), SourceModule('ctypes.util', '/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/util.py'), SourceModule('multiprocessing.sharedctypes', '/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/sharedctypes.py'), SourceModule('setuptools.windows_support', '/usr/local/lib/python3.9/site-packages/setuptools/windows_support.py'), SourceModule('numpy.distutils._shell_utils', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/distutils/_shell_utils.py'), SourceModule('numpy.core._internal', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/core/_internal.py'), SourceModule('numpy.core._dtype_ctypes', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/core/_dtype_ctypes.py'), SourceModule('numpy.ctypeslib', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/ctypeslib.py'), SourceModule('dateutil.tz.win', '/usr/local/lib/python3.9/site-packages/dateutil/tz/win.py'), Package('pandas.io.clipboard', '/usr/local/lib/python3.9/site-packages/pandas/io/clipboard/__init__.py', ['/usr/local/lib/python3.9/site-packages/pandas/io/clipboard']), SourceModule('numpy.core.tests.test_dtype', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/core/tests/test_dtype.py'), SourceModule('numpy.core.tests.test_multiarray', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/core/tests/test_multiarray.py'), SourceModule('numpy.core.tests.test_umath_accuracy', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/core/tests/test_umath_accuracy.py'), SourceModule('numpy.tests.test_ctypeslib', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/tests/test_ctypeslib.py'), SourceModule('numpy.tests.test_public_api', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/tests/test_public_api.py'), SourceModule('numpy.lib.tests.test_io', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/lib/tests/test_io.py'), SourceModule('numpy.random.tests.test_direct', '/usr/local/Cellar/numpy/1.21.2/lib/python3.9/site-packages/numpy/random/tests/test_direct.py')]
*** using recipe: ctypes *** {'prescripts': ['py2app.bootstrap.ctypes_setup']}
*** using recipe: detect_dunder_file *** {'packages': {'numpy', 'pytz', 'pandas', 'certifi', 'matplotlib', 'cv2', 'Cython'}}
Traceback (most recent call last):
  File "/Users/cyril/Desktop/Action Annotator/setup.py", line 14, in <module>
    setup(
  File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 932, in run
    self._run()
  File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 1162, in _run
    self.run_normal()
  File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 1259, in run_normal
    self.process_recipes(mf, filters, flatpackages, loader_files)
  File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 1123, in process_recipes
    find_needed_modules(mf, packages=rval["packages"])
  File "/usr/local/lib/python3.9/site-packages/modulegraph/find_modules.py", line 266, in find_needed_modules
    m = mf.import_hook(package, None, ["*"])
  File "/usr/local/lib/python3.9/site-packages/modulegraph/modulegraph.py", line 1135, in import_hook
    for s in self._ensure_fromlist(m, fromlist):
  File "/usr/local/lib/python3.9/site-packages/modulegraph/modulegraph.py", line 1265, in _ensure_fromlist
    raise ImportError("No module named " + fullname)

This makes no sense to me as opencv-python is definitely installed (e.g. importing it in the Python works fine, and the app.py runs fine...). Any ideas?

Upvotes: 0

Views: 407

Answers (1)

Victoriya Nizhnikova
Victoriya Nizhnikova

Reputation: 21

For error "No module named cv2.config-3.9" this solution works https://github.com/ronaldoussoren/py2app/issues/389 For me renaming config-3.9.py in cv2 dicrectory to config-3.py helped

Upvotes: 1

Related Questions