1

I am trying to convert my .pb model to .onnx and for that I am installing tf2onnx using pip. However, doing that I keep getting following error

C:\Users\HC>pip install -U tf2onnx
Collecting tf2onnx
  Using cached tf2onnx-1.9.3-py3-none-any.whl (435 kB)
Collecting flatbuffers~=1.12
  Using cached flatbuffers-1.12-py2.py3-none-any.whl (15 kB)
Requirement already satisfied: numpy>=1.14.1 in c:\users\hc\appdata\local\programs\python\python310\lib\site-packages (from tf2onnx) (1.22.1)
Requirement already satisfied: requests in c:\users\hc\appdata\local\programs\python\python310\lib\site-packages (from tf2onnx) (2.27.1)
Requirement already satisfied: six in c:\users\hc\appdata\local\programs\python\python310\lib\site-packages (from tf2onnx) (1.16.0)
Collecting onnx>=1.4.1
  Using cached onnx-1.10.2.tar.gz (9.9 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      Traceback (most recent call last):
        File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
          main()
        File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "C:\Users\HC\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "C:\Users\HC\AppData\Local\Temp\pip-build-env-qij5_ixj\overlay\Lib\site-packages\setuptools\build_meta.py", line 162, in get_requires_for_build_wheel
          return self._get_build_requires(
        File "C:\Users\HC\AppData\Local\Temp\pip-build-env-qij5_ixj\overlay\Lib\site-packages\setuptools\build_meta.py", line 143, in _get_build_requires
          self.run_setup()
        File "C:\Users\HC\AppData\Local\Temp\pip-build-env-qij5_ixj\overlay\Lib\site-packages\setuptools\build_meta.py", line 267, in run_setup
          super(_BuildMetaLegacyBackend,
        File "C:\Users\HC\AppData\Local\Temp\pip-build-env-qij5_ixj\overlay\Lib\site-packages\setuptools\build_meta.py", line 158, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 86, in <module>
          assert CMAKE, 'Could not find "cmake" executable!'
      AssertionError: Could not find "cmake" executable!
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Please can anyone guide how to tackle this

Mahi_G
  • 29
  • 1
  • 2

2 Answers2

2

AssertionError: Could not find "cmake" executable! indicates that pip couldn't find cmake. You should install it (https://cmake.org/download/) or add it to your PATH.

Alan Williams
  • 509
  • 1
  • 8
  • 26
  • I installed cmake now im getting error at end note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for onnx Failed to build onnx ERROR: Could not build wheels for onnx, which is required to install pyproject.toml-based projects – Mahi_G Feb 05 '22 at 10:25
  • If you include more of the error as you did in your original question, I’d be able to help. As it stands, it’s hard to tell why the error is occurring. – Alan Williams Feb 06 '22 at 15:51
1

As already stated, the problem is that cmake is not installed. However, you can avoid this problem entirely by using Python 3.9 or 3.8. pip can install pre-compiled onnx for those python versions.

See https://pypi.org/project/onnx/#files

jkr
  • 17,119
  • 2
  • 42
  • 68
  • my python version is 3.10 installed already, now what? and I am unable to instal onnx too saying note: "This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for onnx Failed to build onnx ERROR: Could not build wheels for onnx, which is required to install pyproject.toml-based projects" – Mahi_G Feb 05 '22 at 10:20
  • I am saying that 3.10 is too new for onnx. If you downgrade to 3.9, you will not have to build from source. Your errors arise from attempting to build from source. – jkr Feb 05 '22 at 12:09