fix: update pcb-aoi dependencies for modern Python compatibility#422
fix: update pcb-aoi dependencies for modern Python compatibility#422aryunewaskar77-art wants to merge 2 commits into
Conversation
- opencv-python~=3.4 has no pre-built wheels for Python 3.9+ and attempts to build from source, failing on most modern systems. Updated to >=4.5.0,<4.10.0 which has stable wheels for Python 3.9-3.12 - onnx==1.9.0 (2021) is incompatible with numpy>=1.20+ Updated to >=1.12.0 for modern numpy compatibility - Added numpy>=1.21.0 as explicit dependency Tested on: macOS, Python 3.14 Related to kubeedge#230 Signed-off-by: Aaryaa Newaskar <aryu.newaskar77@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: aryunewaskar77-art The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Code Review
This pull request updates the dependency versions in examples/pcb-aoi/requirements.txt to support Python 3.9+, specifically upgrading OpenCV and ONNX and adding NumPy. The review feedback identifies a likely runtime incompatibility between the specified NumPy version and the legacy TensorFlow 1.x code used in the project. It also suggests using opencv-python-headless for better container portability and requests clarification on the OpenCV version upper bound.
| # version ~=3.4 has no wheels for modern Python and builds from source | ||
| opencv-python>=4.5.0,<4.10.0 | ||
| onnx>=1.12.0 | ||
| numpy>=1.21.0 |
There was a problem hiding this comment.
The requirement numpy>=1.21.0 is likely incompatible with the version of TensorFlow used in this example. The code in basemodel.py (lines 25-26) explicitly uses tensorflow.contrib.slim, which identifies it as TensorFlow 1.x. TensorFlow 1.x is known to break with NumPy 1.20+ due to the removal of several deprecated type aliases (like np.object). While newer NumPy is needed for Python 3.9+ and Apple Silicon support, it will likely cause runtime AttributeError when TensorFlow is used. Please verify if the example has been verified to run (not just install) with this NumPy version.
| onnx==1.9.0 | ||
| # opencv-python pinned to >=4.5 for Python 3.9+ compatibility | ||
| # version ~=3.4 has no wheels for modern Python and builds from source | ||
| opencv-python>=4.5.0,<4.10.0 |
There was a problem hiding this comment.
For edge and server-side deployments (typical for KubeEdge), it is recommended to use opencv-python-headless instead of opencv-python. The headless version does not require X11 or other GUI-related system libraries, making it more portable and easier to install in minimal container environments. Since the code only uses imread and imwrite and does not appear to use any GUI features like cv2.imshow, this should be a safe drop-in replacement.\n\nAdditionally, is there a specific reason for the upper bound <4.10.0? If not, consider allowing the latest stable versions (4.10+) or pinning to a specific known-good version for better reproducibility.
opencv-python-headless>=4.5.0,<4.10.0
- Switch opencv-python to opencv-python-headless for container and edge deployment compatibility (no GUI/X11 required) - Remove upper bound cap on opencv-python-headless version - Pin numpy<1.20.0 for TensorFlow 1.x compatibility (np.object and np.bool aliases were removed in numpy 1.20+) Signed-off-by: Aaryaa Newaskar <aryu.newaskar77@gmail.com>
|
/assign @MooreZheng |
What this PR does
Updates outdated dependencies in
examples/pcb-aoi/requirements.txtthat cause installation failures on modern Python (3.9+).Problem
Two dependencies were broken:
1.
opencv-python~=3.42.
onnx==1.9.0Changes
opencv-python~=3.4→opencv-python>=4.5.0,<4.10.0onnx==1.9.0→onnx>=1.12.0numpy>=1.21.0dependencyVerification
Tested on:
All three packages install successfully with no errors.
Related issues
Related to #230