Open blackCmd opened 3 months ago
please try just by giving opencv instead of opencv-python in requirements.txt, and let me know if it helps you solve the issue.
IMHO This is because packaging removes the "py" files, leaving only the "pyc" files.
As a quick fix, you can add config.py and config3.py to data/flutter_assets/app/app.zip/__pypackages__/cv2/
manually.
( you can take these files from site-packages/cv2/
).
Update: You need to add config.py and config3.py to resulted app.zip
.
This app.zip is created after the build in build/YOUR_PLATFORM/data/flutter_assets/app/
.
The path in app.zip to put the files is /__pypackages__/cv2/
.
please try just by giving opencv instead of opencv-python in requirements.txt, and let me know if it helps you solve the issue.
exactly same issue for me too... Unfortunately it didn't work for me
Traceback (most recent call last):
File "
IMHO This is because packaging removes the "py" files, leaving only the "pyc" files.
As a quick fix, you can add config.py and config3.py to
data/flutter_assets/app/app.zip/__pypackages__/cv2/
manually. ( you can take these files fromsite-packages/cv2/
).
it didn't work neither
IMHO This is because packaging removes the "py" files, leaving only the "pyc" files.
As a quick fix, you can add config.py and config3.py to
data/flutter_assets/app/app.zip/__pypackages__/cv2/
manually. ( you can take these files fromsite-packages/cv2/
).
@ivangermes It didnt work...
please try just by giving opencv instead of opencv-python in requirements.txt, and let me know if it helps you solve the issue.
@lekshmanmj Yes I tried but it didn't work.
Hi, I just had the same error. I use flet 0.22 and opencv 4.9.0.80. manually add the file into the source folder don't work, I also tried to add the folder with .py transform in .pyi but it still doesn't work. Anything new about this problem?
@AltugEngin
it didn't work neither
@blackCmd
It didnt work...
@avagst3
You need to add config.py
and config3.py
to resulted app.zip
.
This app.zip is created after the build in build/YOUR_PLATFORM/data/flutter_assets/app/
.
The path in app.zip to put the files is /__pypackages__/cv2/
.
@ivangermes Thank you very much! I had the same error and it was driving me crazy (I'm a newbie). Then I got this error:
RuntimeError: cannot cache function '_make_tree': no locator available for file 'C:\\Users\\My_user\\AppData\\Local\\Temp\\serious_python_temp32194b5c\\__pypackages__\\pymatting\\util\\kdtree.py'
But applying your solution with those dependencies (copy them where they belong in app.zip everything goes perfect.) 💯
Edit: As the process can be tedious and confusing, I created this tool (with flet XD) It's ugly as hell but it works! The only doubt I have is if it could be a bad practice to include the dependencies like this...
I look forward to hearing your answers Flet Package Loader
@ivangermes I add the file as you say but .exe still use the same Temp folder (so my change is not applyed). Any solution ?
@avagst3
apply it to the generated Flet build
It is in your_project_flet:
\build\windows\data\flutter_assets\app\app.zip
But if you have several dependencies that need this solution I recommend the tool I have created with the solution of @ivangermes
Flet Package Loader
@EmmanuelMMontesinos I use a similar automation. I made a simple bash/python script to add a file to zip. And use it in my CI/CD system.
function add_file_2_zip {
python3 -c "
import zipfile as zf, sys
with zf.ZipFile(sys.argv[1], 'a') as z:
z.write(sys.argv[2], sys.argv[3])
" $1 $2 $3
}
zip_file="/home/user/proj/OpenStitching/build/linux/data/flutter_assets/app/app.zip"
src="/home/user/proj/OpenStitching/venv/lib/python3.11/site-packages/cv2/config.py"
dst="/__pypackages__/cv2/config.py"
add_file_2_zip $zip_file $src $dst
Can anyone help me with this error. I am trying to flet build apk and having opencv-python in my project and getting this installing dependency with error
@Vaibhavsun. its not possible to add python modules with c extensions in apk build.
is there any other similar python library which can be used i just needs to capture using camera and it is easily build with flet apk
is there any other similar python library which can be used i just needs to capture using camera and it is easily build with flet apk
Possibly not. Everything is opencv based these days.
if you want to use flet with opencv on android you have to wait 2-3 months. Entire python ecosystem is moving to android/ios.
You don't need to wait for 2-3 months. We are going to provide pre-built opencv packages with other popular packages in the first order: https://flet.dev/roadmap#packaging
You don't need to wait for 2-3 months. We are going to provide pre-built opencv packages with other popular packages in the first order: https://flet.dev/roadmap#packaging
I am really looking forward to it!
Actually when i was trying with pygrabber which is i think a pure python package then also it is not building and stuck with extracting ?
@Vaibhavsun that's because pygrabber
uses opencv
It has been several months since I posted. It still hasn't been resolved.
flet create myapp
.opencv-python
to requirements.txt in myapp directory.flet build windows ./myapp
.ENV.
Windows10 flet 0.21 and 0.22