Open elvintoh82 opened 2 months ago
@Zeli0
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?
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.
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.
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.
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
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"
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:
Environment: Ubuntu 22.04, Python 3.10.12, Albumentations 1.4.8
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
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