Skip to content

fix: update pcb-aoi dependencies for modern Python compatibility#422

Open
aryunewaskar77-art wants to merge 2 commits into
kubeedge:mainfrom
aryunewaskar77-art:fix/pcb-aoi-update-dependencies
Open

fix: update pcb-aoi dependencies for modern Python compatibility#422
aryunewaskar77-art wants to merge 2 commits into
kubeedge:mainfrom
aryunewaskar77-art:fix/pcb-aoi-update-dependencies

Conversation

@aryunewaskar77-art
Copy link
Copy Markdown

What this PR does

Updates outdated dependencies in examples/pcb-aoi/requirements.txt that cause installation failures on modern Python (3.9+).

Problem

Two dependencies were broken:

1. opencv-python~=3.4

  • Version 3.4 has no pre-built wheels for Python 3.9+
  • Forces a source build which fails on modern macOS and most Linux systems
  • Blocks any new contributor from running this example

2. onnx==1.9.0

  • Released in 2021, incompatible with numpy>=1.20+
  • Causes import errors on modern environments

Changes

  • opencv-python~=3.4opencv-python>=4.5.0,<4.10.0
  • onnx==1.9.0onnx>=1.12.0
  • Added explicit numpy>=1.21.0 dependency

Verification

Tested on:

  • macOS (Apple Silicon)
  • Python 3.14.2

All three packages install successfully with no errors.

Related issues

Related to #230

- 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>
@kubeedge-bot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aryunewaskar77-art
To complete the pull request process, please assign moorezheng after the PR has been reviewed.
You can assign the PR to them by writing /assign @moorezheng in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 9, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread examples/pcb-aoi/requirements.txt Outdated
# 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Comment thread examples/pcb-aoi/requirements.txt Outdated
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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>
@aryunewaskar77-art
Copy link
Copy Markdown
Author

/assign @MooreZheng

@kubeedge-bot kubeedge-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants