简体   繁体   English

mac 上安装 tflite-model-maker 失败

[英]Installation of tflite-model-maker on mac fails

I'm completely new on Python, so using PyCharm 2022.1 I'm trying to install tflite-model-maker on mac but always fail.我在 Python 上是全新的,所以使用 PyCharm 2022.1 我试图在 mac 上安装 tflite-model-maker 但总是失败。 Returned errors are:返回的错误是:

An error occurred while building with CMake.
        Command:
          cmake --build . --target install --config Release --
        Install target:
          install
        Source directory:
          /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f
        Working directory:
          /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/_skbuild/macosx-10.13-x86_64-3.7/cmake-build
      Please check the install target is valid and see CMake's output for more information.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for opencv-python-headless
Failed to build opencv-python-headless
ERROR: Could not build wheels for opencv-python-headless, which is required to install pyproject.toml-based projects

And earlier in the whole terminal report:在整个终端报告的前面:

 In file included from /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/opencv/modules/python/src2/cv2_numpy.cpp:6:
      In file included from /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/opencv/modules/python/src2/cv2_numpy.hpp:4:
      In file included from /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/opencv/modules/python/src2/cv2.hpp:36:
      /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8/overlay/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:242:9: error: use of undeclared identifier 'PyTuple_GET_SIZE'
          if (PyTuple_GET_SIZE(value) != 3) {
              ^
      /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8/overlay/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:245:13: error: use of undeclared identifier 'PyTuple_GET_ITEM'
          title = PyTuple_GET_ITEM(value, 2);
                  ^
      2 errors generated.
      [1091/1100] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2_highgui.cpp.o
      FAILED: modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2_highgui.cpp.o

...

In file included from /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/opencv/modules/python/src2/cv2_highgui.cpp:1:
      In file included from /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/opencv/modules/python/src2/cv2_highgui.hpp:4:
      In file included from /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/opencv/modules/python/src2/cv2.hpp:36:
      /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8/overlay/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:242:9: error: use of undeclared identifier 'PyTuple_GET_SIZE'
          if (PyTuple_GET_SIZE(value) != 3) {
              ^
      /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8/overlay/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:245:13: error: use of undeclared identifier 'PyTuple_GET_ITEM'
          title = PyTuple_GET_ITEM(value, 2);
                  ^
      2 errors generated.
      [1092/1100] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2_util.cpp.o
      FAILED: modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2_util.cpp.o

...

In file included from /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/opencv/modules/python/src2/cv2_util.cpp:1:
      In file included from /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/opencv/modules/python/src2/cv2_util.hpp:4:
      In file included from /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-install-_60a3wey/opencv-python-headless_f3f9ce9981dd47e2bd8cf7f7b304f20f/opencv/modules/python/src2/cv2.hpp:36:
      /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8/overlay/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:242:9: error: use of undeclared identifier 'PyTuple_GET_SIZE'
          if (PyTuple_GET_SIZE(value) != 3) {
              ^
      /private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8/overlay/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:245:13: error: use of undeclared identifier 'PyTuple_GET_ITEM'
          title = PyTuple_GET_ITEM(value, 2);
                  ^
      2 errors generated.
      [1093/1100] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/backends/fluid/gfluidcore_func.avx2.cpp.o
      [1094/1100] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/common/serialization.cpp.o
      [1095/1100] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/backends/fluid/gfluidimgproc_func.avx2.cpp.o
      ninja: build stopped: subcommand failed.
        File "/private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8/overlay/lib/python3.7/site-packages/skbuild/setuptools_wrap.py", line 645, in setup
          cmkr.make(make_args, install_target=cmake_install_target, env=env)
        File "/private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8/overlay/lib/python3.7/site-packages/skbuild/cmaker.py", line 660, in make
          self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
        File "/private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8/overlay/lib/python3.7/site-packages/skbuild/cmaker.py", line 699, in make_impl

And the directory "/private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8" doesn't exists.目录“/private/var/folders/wc/kmpkxd0x57v762v9j6_xcswh0000gn/T/pip-build-env-pt4hwpl8”不存在。

As far as I can understand, errors are found, the process is stopped and the created files and folders are deleted, so at the last command cmake can't find any source folder.据我所知,发现错误,进程停止,创建的文件和文件夹被删除,所以在最后一个命令 cmake 找不到任何源文件夹。 The question is obviously why are those errors (use of undeclared identifier 'PyTuple_GET_SIZE', use of undeclared identifier 'PyTuple_GET_ITEM') found.问题显然是为什么会发现这些错误(使用未声明的标识符“PyTuple_GET_SIZE”,使用未声明的标识符“PyTuple_GET_ITEM”)。 Is it a matter of package versions?是package版本的问题吗? I use python 3.7 and followed information stored in TF requirement page...我使用 python 3.7 并遵循存储在 TF 要求页面中的信息...

Or maybe I'm missing a general option somewhere?或者也许我在某处缺少一般选项?

Also tried to install directly opencv-python-headless but identical result.还尝试直接安装 opencv-python-headless 但结果相同。

I use PyCharm 2022.1.我使用 PyCharm 2022.1。

Any idea will be appreciated.任何想法将不胜感激。

Thanks in advance, regards.在此先感谢,问候。

Maybe you're getting this error because of your pip's version.也许你因为你的 pip 版本而收到这个错误。 Your pip version should be greater than 20.3.您的 pip 版本应大于 20.3。 You can check your pip version using this command:您可以使用以下命令检查您的 pip 版本:

pip -V

Then run this command:然后运行这个命令:

pip install --upgrade pip setuptools wheel

And install opencv-python.并安装 opencv-python。

pip install opencv-python

If these two commands solve your problem you don't have to execute the commands below.如果这两个命令解决了你的问题,你就不必再执行下面的命令了。

And tflite-model-maker also needs sndfile .而且 tflite-model-maker 还需要sndfile On Mac, you can download this package using this command:在 Mac 上,您可以使用以下命令下载此 package:

brew install libsndfile

After running these commands, you can try to install tflite-model-maker.运行这些命令后,您可以尝试安装 tflite-model-maker。 Use this command:使用这个命令:

pip install tflite-model-maker

If this command raise an error, try to install nightly version of tflite-model-maker:如果此命令引发错误,请尝试安装每晚版的 tflite-model-maker:

pip install tflite-model-maker-nightly

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM