opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

pip install build issue

Open DrBwts opened this issue 1 year ago • 3 comments

Expected behaviour

I expected OpenCV's python API to install. I have used the same proceedure in numerous conda environments & have never had a problem like this. In fact it worked just fine yesterday in a different conda env

Actual behaviour

pip installer threw pages & pages of errors, c&p below

Steps to reproduce

As admin, conda activate genicam

Then any of the following,

pip install opencv-contrib-python pip install opencv-contrib-python --user pip install opencv-python pip install opencv-python --user

They all give the same pages & pages of errors

  • operating system - Win 10
  • architecture (e.g. x86) - x64
  • opencv-python version - 4.7.0.72

I would post the errors but "There was an error creating your Issue: body is too long (maximum is 65536 characters). "

So some highlights,

ERROR: Command errored out with exit status 1:
   command: 'C:\ProgramData\Anaconda3\envs\genicam\python.exe' 'C:\ProgramData\Anaconda3\envs\genicam\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\NICBWT~1\AppData\Local\Temp\tmp98_vz8u5'
       cwd: C:\Users\NICBWT~1\AppData\Local\Temp\pip-install-71z9rl7t\opencv-contrib-python_387a51900d48422f8ed4ed222402118d
  Complete output (1205 lines):


  --------------------------------------------------------------------------------
  -- Trying 'Ninja (Visual Studio 17 2022 x64 v143)' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Ninja

    does not support platform specification, but platform

      x64

    was specified.

The LOADS of stuff ending with...

ERROR: Could not build wheels for opencv-contrib-python, which is required to install pyproject.toml-based projects

DrBwts avatar Mar 30 '23 11:03 DrBwts

The logs piece says that pip tries to build the package from source, but does not use pre-built wheel. What is your python version? Python 3.6 was deprecated some time ago. 4.7.0.x was built for Python 3.7+.

asmorkalov avatar Apr 02 '23 11:04 asmorkalov

FYI, it's better to drop 3.6 than to keep supporting it but not provide binaries. If you drop it, then Python 3.6 remain happy with their previously built binaries.

If you are on conda, you should be using conda to get most packages, I think.

You can attach a log file as a .txt by dragging it into GitHub's edit box.

henryiii avatar Apr 11 '23 13:04 henryiii

Thought that error is caused by:

https://github.com/opencv/opencv-python/blob/6b73d90fc3e50ba6858926d299b49f0228e19d68/setup.py#L189-L192

Which is incorrect, scikit-build already handles the platform[^1], and adding a platform this way will break some of the generators, like ninja above.

The interesting error is likely the "MSVC" generator error. Though building from source on Conda with pip is tricky, as it ships its own compiler stack on some platforms, which you might not have installed.

[^1]: I'm pretty sure it does, as I remember writing this code, but it's possible I'm mixing it with something else. But if it is broken it needs to be fixed in scikit-build. Ahh, yes, it's here: https://github.com/scikit-build/scikit-build/blob/66339e23ad65f0c6f6a989c6707a4f2a05430748/skbuild/platform_specifics/abstract.py#L235-L236

henryiii avatar Apr 11 '23 13:04 henryiii