ModuleNotFoundError with distutils on Streamlit

This is my first time using streamlit and I’m facing an issue with deploying my Streamlit app. Here are the details of the problem:

App Link: anprapp.streamlit.app

GitHub Repository: Tirth2742/ANPR-Streamlit-app

Error Message:
[09:41:40] :desktop_computer: Provisioning machine…
[09:41:40] :control_knobs: Preparing system…
[09:41:40] :chains: Spinning up manager process…
[09:41:38] :rocket: Starting up repository: β€˜anpr-streamlit-app’, branch: β€˜main’, main module: β€˜appstream.py’
[09:41:38] :octopus: Cloning repository…
[09:41:39] :octopus: Cloning into β€˜/mount/src/anpr-streamlit-app’…
[09:41:39] :octopus: Cloned repository!
[09:41:39] :octopus: Pulling code changes from Github…
[09:41:40] :package: Processing dependencies…

──────────────────────────────────────── uv ───────────────────────────────────────────

Using uv pip install.

Resolved 87 packages in 401ms

error: Failed to download distributions

Caused by: Failed to fetch wheel: numpy==1.25.0

Caused by: Failed to build: numpy==1.25.0

Caused by: Build backend failed to determine extra requires with build_wheel() with exit status: 1

β€” stdout:

β€” stderr:

Traceback (most recent call last):
File β€œβ€, line 8, in
File β€œ/home/adminuser/.cache/uv/.tmp4vnMBE/.venv/lib/python3.12/site-packages/setuptools/init.py”, line 10, in
import distutils.core
ModuleNotFoundError: No module named β€˜distutils’
…

Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────

[09:42:13] :exclamation: installer returned a non-zero exit code
[09:42:13] :exclamation: Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[09:43:48] :exclamation: Streamlit server consistently failed status checks
[09:43:48] :exclamation: Please fix the errors, push an update to the git repo, or reboot the app.

Streamlit Version: 1.23.1
Python Version: 3.12

Issue Description: The deployment fails with a ModuleNotFoundError for distutils, which seems to be affecting the installation of numpy==1.25.0. It appears that the build environment may be missing necessary components, particularly distutils.

I would appreciate any guidance or suggestions to resolve this issue. Thank you!

distutils has been removed from the Python 3.12 standard library: What’s New In Python 3.12 β€” Python 3.12.5 documentation

You’ll need to include it in your requirements.txt file

You want python<3.12 to install numpy==1.25.0.

I have pip freeze my virtual environment to requirement.txt

now it seem like all dependences are being install successfully and app seems to deployed but

now I’m encountering the following error :
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Stack Trace:
2024-09-02 13:45:43.966 503 GET /script-health-check (127.0.0.1) 101.78ms
─────────────────────── Traceback (most recent call last) ───────────────────────
/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/exec_code.py:88 in exec_func_with_error_handling
/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/script_runner.py:590 in code_to_exec
/mount/src/anpr-streamlit-app/appstream.py:2 in
1 import streamlit as st
❱ 2 import cv2
3 import numpy as np
4 import tensorflow as tf
5 from datetime import datetime
─────────────────────────────────────────────────────────────────────────────────
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Any advice or suggestions would be greatly appreciated!

Thanks in advance for your help.

Try this:

@Goyo after try https://docs.streamlit.io/knowledge-base/dependencies/libgl
this that error is been resolve but new error emerge
and with some more debugging i have update requirements.txt file now i am encountering below error:

/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru
nner/script_runner.py:590 in code_to_exec
/mount/src/anpr-streamlit-app/appstream.py:6 in

3 import numpy as np
4 import tensorflow as tf
5 from datetime import datetime
❱ 6 from object_detection.utils import label_map_util
7 from object_detection.utils import visualization_utils as viz_utils
8 from object_detection.builders import model_builder
9 from object_detection.utils import config_util

/home/adminuser/venv/lib/python3.12/site-packages/object_detection/utils/lab
el_map_util.py:21 in

19 import tensorflow as tf
20 from google.protobuf import text_format
❱ 21 from object_detection.protos import string_int_label_map_pb2
22
24 def _validate_label_map(label_map):

ImportError: cannot import name β€˜string_int_label_map_pb2’ from β€˜object_detection.protos’

The latest release of object-detection is more than five and a half years ago and it seems to be for tensorflow < 1. I also found this:

Which I don’t claim to fully understand (I have never used tensorflow at all), but it seems to imply that, for most practical matters, the TensorFlow Object Detection API has become a dead end.