[Python] Install albumentations with custom opencv-python version using pip?

Discussão em 'Python' iniciado por Stack, Julho 11, 2025.

  1. Stack

    Stack Membro Participativo

    The albumentations package requires some version of opencv-python. From setup.py:

    # If none of packages in first installed, install second package
    CHOOSE_INSTALL_REQUIRES = [
    (
    ("opencv-python>=4.1.1", "opencv-contrib-python>=4.1.1", "opencv-contrib-python-headless>=4.1.1"),
    "opencv-python-headless>=4.1.1",
    )
    ]


    When I pip install, it seems to choose opencv-python-headless, which has a bug that prevents installation. (If you read the bug, it looks like I could install a different version of scikit-build, but that didn't seem to work.)

    The workaround is to install a dev version of opencv-python, which I can with this line in requirements.txt:

    git+https://github.com/opencv/opencv-python@5de8d66d454c8fd946ae17dcfcb285b16aa6049b


    However, while installing albumentations, it decides to still install opencv-python-headless, presumably because the version number (installed from github) doesn't compare well.

    How can I install albumentations and have it use my existing opencv-python install?

    I installed pip-tools, and compiled the requirements for albumentation, and I've been messing with the file, but pip still follows dependencies for each package.

    Can I use pip to install a package directly, without dependencies? Then I could do it one at a time, with the versions I want.

    Continue reading...

Compartilhe esta Página