Can't Build apk when add opencv-python
when try to use flet build apk and add opencv-python in requirement.txt i got this issue when i remove it apk generate successfully
(base) ahmedashraf@ahmeds-mbp app % flet build apk
Creating Flutter bootstrap project...OK
Customizing app icons and splash images...OK
Generating app icons...OK
Generating splash screens...OK
Packaging Python app...Running package command
Creating asset directory: /private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/flet_flutter_build_GUVoHvcXgz/app
Copying Python app from /Users/ahmedashraf/Desktop/app to /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/serious_python_tempbxdo5l
Configured mobile platform with sitecustomize.py at /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/serious_python_sitecustomizeKeuVrR/sitecustomize.py
Installing dependencies with pip command to /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/serious_python_tempbxdo5l/pypackages
Extracting Python distributive from /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/cpython-3.11.6+20231002-aarch64-apple-darwin-install_only.tar.gz to
/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b
/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib/python3.11/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.") error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> [368 lines of output] Ignoring numpy: markers 'python_version == "3.6" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment Ignoring numpy: markers 'python_version == "3.7" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment Ignoring numpy: markers 'python_version == "3.8" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment Ignoring numpy: markers 'python_version <= "3.9" and sys_platform == "linux" and platform_machine == "aarch64"' don't match your environment Ignoring numpy: markers 'python_version <= "3.9" and sys_platform == "darwin" and platform_machine == "arm64"' don't match your environment Ignoring numpy: markers 'python_version == "3.9" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment Ignoring numpy: markers 'python_version == "3.10" and platform_system != "Darwin"' don't match your environment Ignoring numpy: markers 'python_version == "3.10" and platform_system == "Darwin"' don't match your environment Collecting cmake>=3.1 Using cached cmake-3.28.3.tar.gz (42 kB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'done' Collecting numpy==1.22.2 Using cached numpy-1.22.2.zip (11.4 MB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'done' Collecting pip Obtaining dependency information for pip from https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl.metadata Using cached pip-24.0-py3-none-any.whl.metadata (3.6 kB) Collecting scikit-build>=0.14.0 Obtaining dependency information for scikit-build>=0.14.0 from https://files.pythonhosted.org/packages/fa/af/b3ef8fe0bb96bf7308e1f9d196fc069f0c75d9c74cfaad851e418cc704f4/scikit_build-0.17.6-py3-none-any.whl.metadata Using cached scikit_build-0.17.6-py3-none-any.whl.metadata (14 kB) Collecting setuptools==59.2.0 Using cached setuptools-59.2.0-py3-none-any.whl (952 kB) Collecting distro (from scikit-build>=0.14.0) Obtaining dependency information for distro from https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl.metadata Using cached distro-1.9.0-py3-none-any.whl.metadata (6.8 kB) Collecting packaging (from scikit-build>=0.14.0) Obtaining dependency information for packaging from https://files.pythonhosted.org/packages/ec/1a/610693ac4ee14fcdf2d9bf3c493370e4f2ef7ae2e19217d7a237ff42367d/packaging-23.2-py3-none-any.whl.metadata Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB) Collecting wheel>=0.32.0 (from scikit-build>=0.14.0) Obtaining dependency information for wheel>=0.32.0 from https://files.pythonhosted.org/packages/c7/c3/55076fc728723ef927521abaa1955213d094933dc36d4a2008d5101e1af5/wheel-0.42.0-py3-none-any.whl.metadata Using cached wheel-0.42.0-py3-none-any.whl.metadata (2.2 kB) Using cached pip-24.0-py3-none-any.whl (2.1 MB) Using cached scikit_build-0.17.6-py3-none-any.whl (84 kB) Using cached wheel-0.42.0-py3-none-any.whl (65 kB) Using cached distro-1.9.0-py3-none-any.whl (20 kB) Using cached packaging-23.2-py3-none-any.whl (53 kB) Building wheels for collected packages: numpy, cmake Building wheel for numpy (pyproject.toml): started Building wheel for numpy (pyproject.toml): finished with status 'error' error: subprocess-exited-with-error
× Building wheel for numpy (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [174 lines of output]
setup.py:66: RuntimeWarning: NumPy 1.22.2 may not yet support Python 3.11.
warnings.warn(
Running from numpy source directory.
Processing numpy/random/_bounded_integers.pxd.in
Processing numpy/random/_philox.pyx
Processing numpy/random/_bounded_integers.pyx.in
Processing numpy/random/_sfc64.pyx
Processing numpy/random/_mt19937.pyx
Processing numpy/random/bit_generator.pyx
Processing numpy/random/mtrand.pyx
Processing numpy/random/_generator.pyx
Processing numpy/random/_pcg64.pyx
Processing numpy/random/_common.pyx
Cythonizing sources
INFO: blas_opt_info:
INFO: blas_armpl_info:
INFO: customize UnixCCompiler
INFO: C compiler: Cannot_compile_native_modules -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -mmacosx-version-min=11.0
-Wno-nullability-completeness -Wno-expansion-to-defined -Wno-undef-prefix -fPIC -I/var/folders/c8/z52g4gc5679gygt8z0dx0jqm0000gn/T/tmpli8ssce8/tools/deps/include -I/var/folders/c8/z52g4gc5679gygt8z0dx0jqm0000gn/T/tmpli8ssce8/tools/deps/include/ncursesw -I/var/folders/c8/z52g4gc5679gygt8z0dx0jqm0000gn/T/tmpli8ssce8/tools/deps/include/uuid -Werror=unguarded-availability-new
creating /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/tmplfu76awd/var
creating /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/tmplfu76awd/var/folders
creating /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/tmplfu76awd/var/folders/bh
creating /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/tmplfu76awd/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn
creating /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/tmplfu76awd/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T
creating /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/tmplfu76awd/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/tmplfu76awd
INFO: compile options: '-MMD -MF /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/tmplfu76awd/file.c.d -c'
INFO: Cannot_compile_native_modules: /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/tmplfu76awd/file.c
[Errno 2] No such file or directory: 'Cannot_compile_native_modules'
INFO: libraries armpl_lp64_mp not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib',
'/usr/local/lib', '/usr/lib'] INFO: NOT AVAILABLE INFO: INFO: blas_mkl_info: INFO: libraries mkl_rt not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: NOT AVAILABLE INFO: INFO: blis_info: INFO: libraries blis not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: NOT AVAILABLE INFO: INFO: openblas_info: INFO: libraries openblas not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: NOT AVAILABLE INFO: INFO: accelerate_info: INFO: libraries accelerate not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: Library accelerate was not found. Ignoring INFO: libraries veclib not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: Library veclib was not found. Ignoring INFO: FOUND: INFO: extra_compile_args = ['-I/System/Library/Frameworks/vecLib.framework/Headers'] INFO: extra_link_args = ['-Wl,-framework', '-Wl,Accelerate'] INFO: define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)] INFO: INFO: FOUND: INFO: extra_compile_args = ['-I/System/Library/Frameworks/vecLib.framework/Headers'] INFO: extra_link_args = ['-Wl,-framework', '-Wl,Accelerate'] INFO: define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)] INFO: non-existing path in 'numpy/distutils': 'site.cfg' INFO: lapack_opt_info: INFO: lapack_armpl_info: INFO: libraries armpl_lp64_mp not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: NOT AVAILABLE INFO: INFO: lapack_mkl_info: INFO: libraries mkl_rt not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: NOT AVAILABLE INFO: INFO: openblas_lapack_info: INFO: libraries openblas not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: NOT AVAILABLE INFO: INFO: openblas_clapack_info: INFO: libraries openblas,lapack not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: NOT AVAILABLE INFO: INFO: flame_info: INFO: libraries flame not found in ['/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib', '/usr/local/lib', '/usr/lib'] INFO: NOT AVAILABLE INFO: INFO: FOUND: INFO: extra_compile_args = ['-I/System/Library/Frameworks/vecLib.framework/Headers'] INFO: extra_link_args = ['-Wl,-framework', '-Wl,Accelerate'] INFO: define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)] INFO: Warning: attempted relative import with no known parent package /private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-build-env-xsk018b3/overlay/lib/python3.11/site-packages/setuptools/_distutils/dis t.py:275: UserWarning: Unknown distribution option: 'define_macros' warnings.warn(msg) running bdist_wheel running build running config_cc INFO: unifing config_cc, config, build_clib, build_ext, build commands --compiler options running config_fc INFO: unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options running build_src INFO: build_src INFO: building py_modules sources creating build creating build/src.macosx-11.0-arm64-3.11 creating build/src.macosx-11.0-arm64-3.11/numpy creating build/src.macosx-11.0-arm64-3.11/numpy/distutils INFO: building library "npymath" sources WARN: Could not locate executable Cannot_compile_native_modules
[Errno 2] No such file or directory: 'Cannot_compile_native_modules'
Traceback (most recent call last):
File
"/private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_proces
s/_in_process.py", line 353, in
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for numpy
Building wheel for cmake (pyproject.toml): started
Building wheel for cmake (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
× Building wheel for cmake (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [120 lines of output]
/private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-build-env-vi45iqib/overlay/lib/python3.11/site-packages/setuptools_scm/git.py:308
: UserWarning: git archive did not support describe output warnings.warn("git archive did not support describe output") /private/var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/pip-build-env-vi45iqib/overlay/lib/python3.11/site-packages/setuptools_scm/git.py:327 : UserWarning: unprocessed git archival found (no export subst applied) warnings.warn("unprocessed git archival found (no export subst applied)")
--------------------------------------------------------------------------------
-- Trying 'Ninja' generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
Not searching for unused variables given on the command line.
CMake Error at /opt/homebrew/Cellar/cmake/3.28.3/share/cmake/Modules/CMakeDetermineCCompiler.cmake:49 (message):
Could not find compiler set in environment variable CC:
Cannot_compile_native_modules.
Call Stack (most recent call first):
CMakeLists.txt:3 (ENABLE_LANGUAGE)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying 'Ninja' generator - failure
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Trying 'Unix Makefiles' generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
Not searching for unused variables given on the command line.
CMake Error at /opt/homebrew/Cellar/cmake/3.28.3/share/cmake/Modules/CMakeDetermineCCompiler.cmake:49 (message):
Could not find compiler set in environment variable CC:
Cannot_compile_native_modules.
Call Stack (most recent call first):
CMakeLists.txt:3 (ENABLE_LANGUAGE)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying 'Unix Makefiles' generator - failure
--------------------------------------------------------------------------------
=============================DEBUG ASSISTANCE=============================
If you are seeing a compilation error please try the following steps to
successfully install cmake:
1) Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
2) If running on Raspberry Pi OS, you can set PIP_ONLY_BINARY=cmake in
order to retrieve the latest wheels built by piwheels.
c.f. https://github.com/scikit-build/cmake-python-distributions/issues/392#issuecomment-1676284749
3) If on Linux, with glibc < 2.12, you can set PIP_ONLY_BINARY=cmake in
order to retrieve the last manylinux1 compatible wheel.
4) If on Linux, with glibc < 2.12, you can cap "cmake<3.23" in your
requirements in order to retrieve the last manylinux1 compatible wheel.
5) Open an issue with the debug information that follows at
https://github.com/scikit-build/cmake-python-distributions/issues
Python: 3.11.6
platform: macOS-14.3.1-arm64-arm-64bit
macos: 14.3.1
machine: arm64
bits: 64
pip: n/a
setuptools: 69.1.0
scikit-build: 0.17.6
PEP517_BUILD_BACKEND=setuptools.build_meta
=============================DEBUG ASSISTANCE=============================
********************************************************************************
scikit-build could not get a working generator for your system. Aborting build.
Building MacOSX wheels for Python 3.11 requires XCode.
Get it here:
https://developer.apple.com/xcode/
********************************************************************************
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for cmake
Failed to build numpy cmake
ERROR: Could not build wheels for numpy, cmake, which is required to install pyproject.toml-based projects
A new release of pip is available: 23.2.1 -> 24.0
To update, run: /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/bin/python3 -m pip install --upgrade pip
note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
A new release of pip is available: 23.2.1 -> 24.0 To update, run: /var/folders/bh/m3lvt7gs139_2xqjg2vxt9q80000gn/T/hostpython3.11_wmxN2b/python/bin/python3 -m pip install --upgrade pip
Error building Flet app - see the log of failed command above. (base) ahmedashraf@ahmeds-mbp app %
i follow this steps btw https://flet.dev/docs/guides/python/packaging-app-for-distribution#native-python-packages but nothing work
Same
Same problem, but I cant build when using firebase_admin
up
OpenCV should be built following this guide: https://flet.dev/docs/publish/android#prerequisites
firebase_admin is more challenging. This is firebase-admin dependencies:
% pipgrip firebase_admin
firebase-admin==6.5.0
cachecontrol==0.14.0
msgpack==1.0.8
requests==2.31.0
certifi==2024.2.2
charset-normalizer==3.3.2
idna==3.7
urllib3==2.2.1
google-api-core==2.18.0
google-auth==2.29.0
cachetools==5.3.3
pyasn1-modules==0.4.0
pyasn1==0.6.0
rsa==4.9
googleapis-common-protos==1.63.0
protobuf==4.25.3
grpcio-status==1.62.2
grpcio==1.62.2
proto-plus==1.23.0
google-api-python-client==2.127.0
google-auth-httplib2==0.2.0
httplib2==0.22.0
pyparsing==3.1.2
uritemplate==4.1.1
google-cloud-firestore==2.16.0
google-cloud-core==2.4.1
google-cloud-storage==2.16.0
google-crc32c==1.5.0
google-resumable-media==2.7.0
pyjwt==2.8.0
cryptography==42.0.5
cffi==1.16.0
pycparser==2.22
Kivy does not have (or outdated) recipes for some native packages required for that package:
-
grpcio- absent -
google-crc32c- absent -
msgpack- outdated -
protobuf- outdated -
pycparser- outdated
We are currently working on packaging improvements using a different approach, not relying on Kivy anymore. It will be available in a few weeks. I know it hurts, but thank you for your patience.
For curious this is the list of Python packages I'm trying to assemble from various frameworks, to understand what should be supported in Flet first of all: https://docs.google.com/spreadsheets/d/1bZwiWyxWzReJmSd6iOlZVRNWLa9oYV0ci49coRJzZss/edit?usp=sharing
I'm going to create a voting section on the forums to collect everyone's feedback.
Same problem, but I cant build when using firebase_admin
did you find solution bro
Any solution so far??😵💫 I also can’t build apk using python-opencv
OpenCV should be built following this guide: https://flet.dev/docs/publish/android#prerequisites
firebase_adminis more challenging. This isfirebase-admindependencies:% pipgrip firebase_admin firebase-admin==6.5.0 cachecontrol==0.14.0 msgpack==1.0.8 requests==2.31.0 certifi==2024.2.2 charset-normalizer==3.3.2 idna==3.7 urllib3==2.2.1 google-api-core==2.18.0 google-auth==2.29.0 cachetools==5.3.3 pyasn1-modules==0.4.0 pyasn1==0.6.0 rsa==4.9 googleapis-common-protos==1.63.0 protobuf==4.25.3 grpcio-status==1.62.2 grpcio==1.62.2 proto-plus==1.23.0 google-api-python-client==2.127.0 google-auth-httplib2==0.2.0 httplib2==0.22.0 pyparsing==3.1.2 uritemplate==4.1.1 google-cloud-firestore==2.16.0 google-cloud-core==2.4.1 google-cloud-storage==2.16.0 google-crc32c==1.5.0 google-resumable-media==2.7.0 pyjwt==2.8.0 cryptography==42.0.5 cffi==1.16.0 pycparser==2.22Kivy does not have (or outdated) recipes for some native packages required for that package:
grpcio- absentgoogle-crc32c- absentmsgpack- outdatedprotobuf- outdatedpycparser- outdatedWe are currently working on packaging improvements using a different approach, not relying on Kivy anymore. It will be available in a few weeks. I know it hurts, but thank you for your patience.
I have followed that guide only, now getting cv2 import error in my android app! plz help @FeodorFitsner
Closing in favour of https://github.com/flet-dev/flet/issues/3839