Issue forcing custom OpenCV version in Python3

I am having an issue with trying to downgrade a version of OpenCV for a Python3 script in Grasshopper, as I need some functions which have been removed in the newer OpenCV version that ships with the current Rhino release.

I just added the standard requirements line with a custom version:

# r: opencv-contrib-python==4.6.0.66

but get this error, which seems to suggest that RhinoCode is only reading the first three digits of the version I am trying to use:

Error building script: Could not find a version that satisfies the requirement opencv-contrib-python==4.6.0 (from versions: 3.4.11.45, 3.4.13.47, 3.4.14.51, 3.4.14.53, 3.4.15.55, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.4.0.46, 4.5.1.48, 4.5.2.52, 4.5.2.54, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66, 4.7.0.68, 4.7.0.72, 4.8.0.74, 4.8.0.76, 4.8.1.78, 4.9.0.80, 4.10.0.82, 4.10.0.84, 4.11.0.86, 4.12.0.88, 4.13.0.90, 4.13.0.92, 4.14.0.94, 5.0.0.93)

Am I doing something wrong or is there something I should be aware with versioning for Python3 packages?

Ciao Andrea ,
The cleanest workaround is probably to install the exact OpenCV version separately instead of using the # r: line, and then point Python to where it’s installed. You could also use a dedicated # venv: environment so you can keep that specific version isolated from the one Rhino normally uses.
Sounds like a Parser bug on RhinoCode side :slight_smile:
Hope this helps,
Farouk

Thanks Farouk, that definitetly helps getting things going.

However, it would be great to have it supported, as I might need to distribute the script to others, and it becomes a bit cumbersome to have to install it manually for multiple people.