Skip to content
Can`t use "opencv-python" in my project
Profile icon
Igor-Belskiy

Consol show me this:

Replit: Updating package configuration

--> python3 -m poetry add opencv-python
Using version ^4.5.4 for opencv-python

Updating dependencies
Resolving dependencies...

SolverProblemError

The current project's Python requirement (>=3.8,<4.0) is not compatible with some of the required packages Python requirement:
- numpy requires Python >=3.7,<3.11, so it will not be satisfied for Python >=3.11,<4.0
- numpy requires Python >=3.7,<3.11, so it will not be satisfied for Python >=3.11,<4.0
- numpy requires Python >=3.7,<3.11, so it will not be satisfied for Python >=3.11,<4.0

Because no versions of numpy match >1.21.2,<1.21.3 || >1.21.3,<1.21.4 || >1.21.4
and numpy (1.21.2) requires Python >=3.7,<3.11, numpy is forbidden.
And because numpy (1.21.3) requires Python >=3.7,<3.11
and numpy (1.21.4) requires Python >=3.7,<3.11, numpy is forbidden.
Because no versions of opencv-python match >=4.5.4,<4.5.4.58 || >4.5.4.58,<5.0.0
and opencv-python (4.5.4.58) depends on numpy (>=1.21.2), opencv-python (>=4.5.4,<5.0.0) requires numpy (>=1.21.2).
Thus, opencv-python is forbidden.
So, because repl-python3-computervision-hands depends on opencv-python (^4.5.4), version solving failed.

at /opt/virtualenvs/python3/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes

• Check your dependencies Python requirement: The Python requirement can be specified via the python or markers properties

For numpy, a possible solution would be to set the `python` property to ">=3.8,<3.11" For numpy, a possible solution would be to set the `python` property to ">=3.8,<3.11" For numpy, a possible solution would be to set the `python` property to ">=3.8,<3.11" https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies, https://python-poetry.org/docs/dependency-specification/#using-environment-markers

exit status 1

Replit: Package operation failed.


Looks like numpy can`t work with python 3.8 version.

Have any ideas how to solve this problem?

You are viewing a single comment. View All
Profile icon
filipclone

I manged to get it working. The issue is opencv-python from package manager seems to depend on a version of numpy that is incompatible with python 3.8. So is going to fail. You cannot use the package manager. You need to go to console and do pip install opencv-python then pip install numpy right after that. You might also want to instal opencv-python from package manager to get it failing once just so that replit recognizes cv2. It will NOT show up in the package manager list but python code seems to recognize it regardless.

If you read the error it literally tells you what the issue is. "Because no versions of numpy match >1.21.2,<1.21.3 || >1.21.3,<1.21.4 || >1.21.4
and numpy (1.21.2) requires Python >=3.7,<3.11, numpy is forbidden." ie the version that is trying to install is not compatible with python 3.7+

Someone should report it . I am guessing the issue is the package requirements are wrong for opencv-python and uses an incorrect version of numpy for Python 3.8.2.