flet-dev / serious-python

Python runtime for Flutter apps
Apache License 2.0
211 stars 22 forks source link

ModuleNotFoundError: No module named 'numpy' #75

Open Umar888 opened 9 months ago

Umar888 commented 9 months ago

I am building a flutter project and want to use python scripts in my project, this is how i integrated. I will explain step by step:

This is my python code

import os
import numpy as np
from PIL import Image
image_paths_string = os.getenv("IMAGE_PATHS")
result_filename = os.getenv("RESULT_FILENAME")
process_type = os.getenv("PROCESS_TYPE")
if not image_paths_string or not result_filename or not process_type:
    print("Required environment variables are not set.")
    exit(1)
image_paths = image_paths_string.split(",")
results = []
for image_path in image_paths:
    try:
        with Image.open(image_path) as img:
            img_array = np.array(img)
            average_color = np.mean(img_array, axis=(0, 1))
            results.append(f"Image: {image_path}, Average Color: {average_color}")
    except Exception as e:
        results.append(f"Error processing {image_path}: {str(e)}")
with open(result_filename, "w") as f:
    for result in results:
        f.write(result + "\n")

My python is placed in app directory inside flutter project directory. Full Path /Users/umarghaffar/StudioProjects/python_text/app/tf.py

Here is the picture of my directory map

Screenshot 2024-02-22 at 2 34 06 PM

Kindly help me to resolve my issue. Let me know where I am doing wrong

Umar888 commented 9 months ago

@FeodorFitsner