Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opencv-python-headless continues to be installed despite meeting MIN_OPENCV_VERSION with opencv-python #1785

Open
elvintoh82 opened this issue Jun 11, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@elvintoh82
Copy link

elvintoh82 commented Jun 11, 2024

Running in docker, I already have opencv-python 4.9.0.80 (pip installed).
I then run pip install albumentations --no-binary albumentations so that I can have albumentations WITHOUT opencv-python-headless.

Upon pip installation, albumentations (1.4.8) will still (wrongly) install opencv-python-headless (4.10.0.82).
This results in the system having 2 opencv installations (conflict).

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior:

  1. Environment: Ubuntu 22.04, Python 3.10.12, Albumentations 1.4.8

  2. Sample dockerfile to re-enact this bug.
    FROM ros:humble-ros-base
    RUN apt-get update && apt-get install -y python3-pip
    RUN pip install --upgrade pip
    RUN pip install opencv-python==4.9.0.80
    RUN pip install albumentations --no-binary albumentations

  3. It doesn't say error, but it will just wrongly install opencv-python-headless 4.10.0.82, despite already having the opencv-python 4.9.0.80 which meets the min opencv version. This dual installation of cv2 will result in my image having a headless version dominating, hence blocking my other programs that would need an opencv with gui capabilities.

Expected behavior

This argument (no binary) of pip installation of albumentations is supposed to NOT install opencv-python-headless, i.a.w. https://albumentations.ai/docs/getting_started/installation/.

Actual behavior

In the end, 2 conflicting versions of opencv exists. pip list |grep open
opencv-python 4.9.0.80
opencv-python-headless 4.10.0.82

Additional context

For me, I can't live with using a headless opencv in this docker image. During the development stage, I require plenty of testing (visually checking the images, most commonly using cv2.imshow) using GUI. This installation of opencv-python-headless when pip installing Albumentations is causing me the inability to use opencv's GUI. (not really keen on using QT's gui just to display an image).

Oh yah, in case anyone wants to know. If I have opencv-python 4.10.0.82 installed, and then pip install albumentations --no-binary albumentations, it will not install the opencv-python-headless.
For argument sake, i would like to just use 4.9.0.80 or an even lower version like 4.6.0.66 of opencv-python

@elvintoh82 elvintoh82 added the bug Something isn't working label Jun 11, 2024
@elvintoh82
Copy link
Author

@Zeli0

@ternaus
Copy link
Collaborator

ternaus commented Jun 11, 2024

I am not really an expert on how pip handles depencencies, especially dynamic ones.

If someone knows how to do it better - would be great.

First issue that I see is that

pip install albumentations --no-binary albumentations

Does not behave as expected and! We do not have a check in CI/CD to check for that.

Second is that overall dynamic dependencies do not work as expected.

@elvintoh82

Does this work if write it like

RUN pip install opencv-python==4.9.0.80
RUN pip install albumentations --no-binary albumentations

I.e. switch lines?

@elvintoh82
Copy link
Author

I am not really an expert on how pip handles depencencies, especially dynamic ones.

If someone knows how to do it better - would be great.

First issue that I see is that

pip install albumentations --no-binary albumentations

Does not behave as expected and! We do not have a check in CI/CD to check for that.

Second is that overall dynamic dependencies do not work as expected.

@elvintoh82

Does this work if write it like

RUN pip install opencv-python==4.9.0.80
RUN pip install albumentations --no-binary albumentations

I.e. switch lines?

Hi, did you instead mean run the installation of albumentations first, followed by installation of opencv-python?
I'll do a quick try now.

@elvintoh82
Copy link
Author

I've tried reversing the sequence as stated above. pip installation of albumentations followed by opencv-python does not show any errors. But inside python, importing cv2 immediately breaks.
Screenshot from 2024-06-12 09-58-05

@elvintoh82
Copy link
Author

Feeling adventurous, I tried to follow the original sequence. opencv-python then albumentations then ADDED a new line of uninstalling opencv-python-headless.

FROM ros:humble-ros-base
RUN apt-get update && apt-get install -y python3-pip
RUN pip install --upgrade pip
RUN pip install opencv-python==4.9.0.80
RUN pip install albumentations --no-binary albumentations
RUN pip uninstall opencv-python-headless

There were no errors during the uninstallation of headless. I then went into python to do some basic test of cv2.
import cv2 yields no error, but it is already damaged when I tried to print cv2.version (no such attribute), file shows empty. And some other basic functions shows problems as well.
Screenshot from 2024-06-12 10-05-21

@ternaus
Copy link
Collaborator

ternaus commented Jun 12, 2024

What about

FROM ros:humble-ros-base
RUN apt-get update && apt-get install -y python3-pip
RUN pip install --upgrade pip
RUN pip uninstall opencv-python opencv-python-headless
RUN pip install albumentations --no-binary albumentations
RUN pip install opencv-python==4.9.0.80

Could ros:humble-ros-base has opencv opencv-heasdless being already instsalled so that is messes with the installation

@elvintoh82
Copy link
Author

What about

FROM ros:humble-ros-base
RUN apt-get update && apt-get install -y python3-pip
RUN pip install --upgrade pip
RUN pip uninstall opencv-python opencv-python-headless
RUN pip install albumentations --no-binary albumentations
RUN pip install opencv-python==4.9.0.80

Could ros:humble-ros-base has opencv opencv-heasdless being already instsalled so that is messes with the installation

just did a quick check and no opencv exists under ros:humble-ros-base. Not even under "apt install"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants