在Ubuntu 20.04中使用pip安装onnx时出错

时间:2020-04-25 22:20:24

标签: python-3.x pip onnx ubuntu-20.04

我正在尝试在全新的Ubuntu 20.04安装中安装onnx,但是我遇到了以下错误。似乎我需要protobuf编译器,尽管我还没有找到任何说明我需要安装该软件包的文档。

$ sudo python3 -m pip install 'onnx>=1.1.2'
Collecting onnx>=1.1.2
  Using cached onnx-1.6.0.tar.gz (3.1 MB)
Requirement already satisfied: numpy in /usr/local/lib/python3.8/dist-packages (from onnx>=1.1.2) (1.18.3)
Requirement already satisfied: protobuf in /usr/lib/python3/dist-packages (from onnx>=1.1.2) (3.6.1)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from onnx>=1.1.2) (1.14.0)
Requirement already satisfied: typing-extensions>=3.6.2.1 in /usr/local/lib/python3.8/dist-packages (from onnx>=1.1.2) (3.7.4.2)
Building wheels for collected packages: onnx
  Building wheel for onnx (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-akurq0e8/onnx/setup.py'"'"'; __file__='"'"'/tmp/pip-install-akurq0e8/onnx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-zmzgb0kg
       cwd: /tmp/pip-install-akurq0e8/onnx/
  Complete output (64 lines):
  fatal: not a git repository (or any of the parent directories): .git
  running bdist_wheel
  running build
  running build_py
  running create_version
  running cmake_build
  -- The C compiler identification is GNU 9.3.0
  -- The CXX compiler identification is GNU 9.3.0
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  Generated: /tmp/pip-install-akurq0e8/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto
  CMake Error at CMakeLists.txt:248 (message):
    Protobuf compiler not found
  Call Stack (most recent call first):
    CMakeLists.txt:279 (relative_protobuf_generate_cpp)


  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-install-akurq0e8/onnx/.setuptools-cmake-build/CMakeFiles/CMakeOutput.log".
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-akurq0e8/onnx/setup.py", line 315, in <module>
      setuptools.setup(
    File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/lib/python3/dist-packages/wheel/bdist_wheel.py", line 223, in run
      self.run_command('build')
    File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-akurq0e8/onnx/setup.py", line 209, in run
      self.run_command('cmake_build')
    File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-akurq0e8/onnx/setup.py", line 195, in run
      subprocess.check_call(cmake_args)
    File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/usr/bin/cmake', '-DPYTHON_INCLUDE_DIR=/usr/include/python3.8', '-DPYTHON_EXECUTABLE=/usr/bin/python3', '-DBUILD_ONNX_PYTHON=ON', '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '-DONNX_NAMESPACE=onnx', '-DPY_EXT_SUFFIX=.cpython-38-x86_64-linux-gnu.so', '-DCMAKE_BUILD_TYPE=Release', '-DONNX_ML=1', '/tmp/pip-install-akurq0e8/onnx']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for onnx
  Running setup.py clean for onnx
Failed to build onnx
Installing collected packages: onnx
    Running setup.py install for onnx ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-akurq0e8/onnx/setup.py'"'"'; __file__='"'"'/tmp/pip-install-akurq0e8/onnx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-txzgh5wg/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/onnx
         cwd: /tmp/pip-install-akurq0e8/onnx/
    Complete output (52 lines):
    fatal: not a git repository (or any of the parent directories): .git
    running install
    running build
    running build_py
    running create_version
    running cmake_build
    Generated: /tmp/pip-install-akurq0e8/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto
    CMake Error at CMakeLists.txt:248 (message):
      Protobuf compiler not found
    Call Stack (most recent call first):
      CMakeLists.txt:279 (relative_protobuf_generate_cpp)


    -- Configuring incomplete, errors occurred!
    See also "/tmp/pip-install-akurq0e8/onnx/.setuptools-cmake-build/CMakeFiles/CMakeOutput.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-akurq0e8/onnx/setup.py", line 315, in <module>
        setuptools.setup(
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib/python3.8/distutils/command/install.py", line 589, in run
        self.run_command('build')
      File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-akurq0e8/onnx/setup.py", line 209, in run
        self.run_command('cmake_build')
      File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-akurq0e8/onnx/setup.py", line 195, in run
        subprocess.check_call(cmake_args)
      File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['/usr/bin/cmake', '-DPYTHON_INCLUDE_DIR=/usr/include/python3.8', '-DPYTHON_EXECUTABLE=/usr/bin/python3', '-DBUILD_ONNX_PYTHON=ON', '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '-DONNX_NAMESPACE=onnx', '-DPY_EXT_SUFFIX=.cpython-38-x86_64-linux-gnu.so', '-DCMAKE_BUILD_TYPE=Release', '-DONNX_ML=1', '/tmp/pip-install-akurq0e8/onnx']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-akurq0e8/onnx/setup.py'"'"'; __file__='"'"'/tmp/pip-install-akurq0e8/onnx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-txzgh5wg/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/onnx Check the logs for full command output.

然后我尝试安装protobuf编译器(sudo apt install protobuf-compiler),现在又遇到了另一个错误,这似乎表明安装过程中的某些脚本需要python二进制文件。由于这是Ubuntu 20.04,因此未安装python 2.7,并且不存在python二进制文件。

 sudo pip3 install 'onnx>=1.1.2'
Collecting onnx>=1.1.2
  Using cached onnx-1.6.0.tar.gz (3.1 MB)
Requirement already satisfied: numpy in /usr/local/lib/python3.8/dist-packages (from onnx>=1.1.2) (1.18.3)
Requirement already satisfied: protobuf in /usr/lib/python3/dist-packages (from onnx>=1.1.2) (3.6.1)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from onnx>=1.1.2) (1.14.0)
Requirement already satisfied: typing-extensions>=3.6.2.1 in /usr/local/lib/python3.8/dist-packages (from onnx>=1.1.2) (3.7.4.2)
Building wheels for collected packages: onnx
  Building wheel for onnx (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-t7al85w7/onnx/setup.py'"'"'; __file__='"'"'/tmp/pip-install-t7al85w7/onnx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-30aavuu6
       cwd: /tmp/pip-install-t7al85w7/onnx/
  Complete output (135 lines):
  fatal: not a git repository (or any of the parent directories): .git
  running bdist_wheel
  running build
  running build_py
  running create_version
  running cmake_build
  -- The C compiler identification is GNU 9.3.0
  -- The CXX compiler identification is GNU 9.3.0
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found version "3.6.1")
  Generated: /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto
  Generated: /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build/onnx/onnx-operators-ml.proto
  CMake Warning at CMakeLists.txt:394 (find_package):
    By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has
    asked CMake to find a package configuration file provided by "pybind11",
    but CMake did not find one.

    Could not find a package configuration file provided by "pybind11"
    (requested version 2.2) with any of the following names:

      pybind11Config.cmake
      pybind11-config.cmake

    Add the installation prefix of "pybind11" to CMAKE_PREFIX_PATH or set
    "pybind11_DIR" to a directory containing one of the above files.  If
    "pybind11" provides a separate development package or SDK, be sure it has
    been installed.


  --
  -- ******** Summary ********
  --   CMake version         : 3.16.3
  --   CMake command         : /usr/bin/cmake
  --   System                : Linux
  --   C++ compiler          : /usr/bin/c++
  --   C++ compiler version  : 9.3.0
  --   CXX flags             :  -Wnon-virtual-dtor
  --   Build type            : Release
  --   Compile definitions   :
  --   CMAKE_PREFIX_PATH     :
  --   CMAKE_INSTALL_PREFIX  : /usr/local
  --   CMAKE_MODULE_PATH     :
  --
  --   ONNX version          : 1.6.0
  --   ONNX NAMESPACE        : onnx
  --   ONNX_BUILD_TESTS      : OFF
  --   ONNX_BUILD_BENCHMARKS : OFF
  --   ONNX_USE_LITE_PROTO   : OFF
  --   ONNXIFI_DUMMY_BACKEND : OFF
  --   ONNXIFI_ENABLE_EXT    : OFF
  --
  --   Protobuf compiler     : /usr/bin/protoc
  --   Protobuf includes     : /usr/include
  --   Protobuf libraries    : /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread
  --   BUILD_ONNX_PYTHON     : ON
  --     Python version      :
  --     Python executable   : /usr/bin/python3
  --     Python includes     : /usr/include/python3.8
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build
  Scanning dependencies of target gen_onnx_proto
  Scanning dependencies of target onnxifi_loader
  Scanning dependencies of target onnxifi_dummy
  [  1%] Building C object CMakeFiles/onnxifi_dummy.dir/onnx/onnxifi_dummy.c.o
  [  3%] Building C object CMakeFiles/onnxifi_loader.dir/onnx/onnxifi_loader.c.o
  [  4%] Running gen_proto.py on onnx/onnx.in.proto
  /tmp/pip-install-t7al85w7/onnx/onnx/onnxifi_dummy.c: In function ‘onnxGetExtensionFunctionAddress’:
  /tmp/pip-install-t7al85w7/onnx/onnx/onnxifi_dummy.c:173:21: warning: assignment to ‘onnxExtensionFunctionPointer’ {aka ‘int (*)(void)’} from incompatible pointer type ‘onnxStatus (*)(void *, const char *, onnxStatus (**)(void))’ {aka ‘int (*)(void *, const char *, int (**)(void))’} [-Wincompatible-pointer-types]
    173 |           *function = &onnxGetExtensionFunctionAddress;
        |                     ^
  /tmp/pip-install-t7al85w7/onnx/onnx/onnxifi_dummy.c:176:21: warning: assignment to ‘onnxExtensionFunctionPointer’ {aka ‘int (*)(void)’} from incompatible pointer type ‘onnxStatus (*)(void *, uint32_t,  const onnxTensorDescriptorV1 *, uint32_t,  const onnxTensorDescriptorV1 *, onnxMemoryFenceV1 *)’ {aka ‘int (*)(void *, unsigned int,  const struct onnxTensorDescriptorV1 *, unsigned int,  const struct onnxTensorDescriptorV1 *, struct onnxMemoryFenceV1 *)’} [-Wincompatible-pointer-types]
    176 |           *function = &onnxSetIOAndRunGraph;
        |                     ^
  Processing /tmp/pip-install-t7al85w7/onnx/onnx/onnx.in.proto
  Writing /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto
  Writing /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto3
  generating /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build/onnx/onnx_pb.py
  [  6%] Running C++ protocol buffer compiler on /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto
  [  8%] Linking C static library libonnxifi_loader.a
  /usr/bin/env: ‘python’: No such file or directory
  --mypy_out: protoc-gen-mypy: Plugin failed with status code 127.
  make[2]: *** [CMakeFiles/gen_onnx_proto.dir/build.make:62: onnx/onnx-ml.pb.cc] Error 1
  make[1]: *** [CMakeFiles/Makefile2:250: CMakeFiles/gen_onnx_proto.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....
  [  9%] Linking C shared library libonnxifi_dummy.so
  [  9%] Built target onnxifi_loader
  [  9%] Built target onnxifi_dummy
  make: *** [Makefile:130: all] Error 2
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-t7al85w7/onnx/setup.py", line 315, in <module>
      setuptools.setup(
    File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/lib/python3/dist-packages/wheel/bdist_wheel.py", line 223, in run
      self.run_command('build')
    File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-t7al85w7/onnx/setup.py", line 209, in run
      self.run_command('cmake_build')
    File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-t7al85w7/onnx/setup.py", line 203, in run
      subprocess.check_call(build_args)
    File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/usr/bin/cmake', '--build', '.', '--', '-j', '12']' returned non-zero exit status 2.
  ----------------------------------------
  ERROR: Failed building wheel for onnx
  Running setup.py clean for onnx
Failed to build onnx
Installing collected packages: onnx
    Running setup.py install for onnx ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-t7al85w7/onnx/setup.py'"'"'; __file__='"'"'/tmp/pip-install-t7al85w7/onnx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-b60n_z7m/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/onnx
         cwd: /tmp/pip-install-t7al85w7/onnx/
    Complete output (107 lines):
    fatal: not a git repository (or any of the parent directories): .git
    running install
    running build
    running build_py
    running create_version
    running cmake_build
    Generated: /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto
    Generated: /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build/onnx/onnx-operators-ml.proto
    CMake Warning at CMakeLists.txt:394 (find_package):
      By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has
      asked CMake to find a package configuration file provided by "pybind11",
      but CMake did not find one.

      Could not find a package configuration file provided by "pybind11"
      (requested version 2.2) with any of the following names:

        pybind11Config.cmake
        pybind11-config.cmake

      Add the installation prefix of "pybind11" to CMAKE_PREFIX_PATH or set
      "pybind11_DIR" to a directory containing one of the above files.  If
      "pybind11" provides a separate development package or SDK, be sure it has
      been installed.


    --
    -- ******** Summary ********
    --   CMake version         : 3.16.3
    --   CMake command         : /usr/bin/cmake
    --   System                : Linux
    --   C++ compiler          : /usr/bin/c++
    --   C++ compiler version  : 9.3.0
    --   CXX flags             :  -Wnon-virtual-dtor
    --   Build type            : Release
    --   Compile definitions   :
    --   CMAKE_PREFIX_PATH     :
    --   CMAKE_INSTALL_PREFIX  : /usr/local
    --   CMAKE_MODULE_PATH     :
    --
    --   ONNX version          : 1.6.0
    --   ONNX NAMESPACE        : onnx
    --   ONNX_BUILD_TESTS      : OFF
    --   ONNX_BUILD_BENCHMARKS : OFF
    --   ONNX_USE_LITE_PROTO   : OFF
    --   ONNXIFI_DUMMY_BACKEND : OFF
    --   ONNXIFI_ENABLE_EXT    : OFF
    --
    --   Protobuf compiler     : /usr/bin/protoc
    --   Protobuf includes     : /usr/include
    --   Protobuf libraries    : /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread
    --   BUILD_ONNX_PYTHON     : ON
    --     Python version      :
    --     Python executable   : /usr/bin/python3
    --     Python includes     : /usr/include/python3.8
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build
    [  1%] Running C++ protocol buffer compiler on /tmp/pip-install-t7al85w7/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto
    [  4%] Built target onnxifi_dummy
    [  8%] Built target onnxifi_loader
    Scanning dependencies of target onnxifi_wrapper
    /usr/bin/env: ‘python’: No such file or directory
    --mypy_out: protoc-gen-mypy: Plugin failed with status code 127.
    make[2]: *** [CMakeFiles/gen_onnx_proto.dir/build.make:62: onnx/onnx-ml.pb.cc] Error 1
    make[1]: *** [CMakeFiles/Makefile2:250: CMakeFiles/gen_onnx_proto.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....
    [  9%] Building C object CMakeFiles/onnxifi_wrapper.dir/onnx/onnxifi_wrapper.c.o
    [ 11%] Linking C shared module libonnxifi.so
    [ 11%] Built target onnxifi_wrapper
    make: *** [Makefile:130: all] Error 2
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-t7al85w7/onnx/setup.py", line 315, in <module>
        setuptools.setup(
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib/python3.8/distutils/command/install.py", line 589, in run
        self.run_command('build')
      File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-t7al85w7/onnx/setup.py", line 209, in run
        self.run_command('cmake_build')
      File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-t7al85w7/onnx/setup.py", line 203, in run
        subprocess.check_call(build_args)
      File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['/usr/bin/cmake', '--build', '.', '--', '-j', '12']' returned non-zero exit status 2.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-t7al85w7/onnx/setup.py'"'"'; __file__='"'"'/tmp/pip-install-t7al85w7/onnx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-b60n_z7m/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/onnx Check the logs for full command output.

为避免此问题,可以建立符号链接,以便python命令实际运行python3。

2 个答案:

答案 0 :(得分:3)

总而言之,要在Ubuntu 20.04中成功安装onnx,您需要:

1)安装protobuf编译器:sudo apt install protobuf-compiler

2)建立从python3到python的链接:sudo ln -s /usr/bin/python3 /usr/bin/python

注意:也许我错过了另一个依赖项,在安装OpenVINO依赖项时我已经安装了许多其他软件包。

答案 1 :(得分:2)

仅在Ubuntu 18.04上验证了tgonzaleza的提示。 修复之后,显示以下错误: 找不到Protobuf(缺少:Protobuf_INCLUDE_DIR) 可以这样解决:

sudo apt-get install libprotobuf-dev