最近因为一些原因需要用到 tflite-support 这个库,但是当使用 pip 安装时出现错误,具体错误如下:
C:\Users\xxxxx\AppData\Local\Programs\Python\Python3x\lib\site-packages\setuptools\command\build_py.py:202: SetuptoolsDeprecationWarning: Installing 'tflite_support.flatbuffers' as data is deprecated, please list it in `packages`.
!!
############################
# Package would be ignored #
############################
Python recognizes 'tflite_support.flatbuffers' as an importable package,
but it is not listed in the `packages` configuration of setuptools.
'tflite_support.flatbuffers' has been automatically added to the distribution only
because it may contain data files, but this behavior is likely to change
in future versions of setuptools (and therefore is considered deprecated).
Please make sure that 'tflite_support.flatbuffers' is included as a package by using
the `packages` configuration field or the proper discovery methods
(for example by using `find_namespace_packages(...)`/`find_namespace:`
instead of `find_packages(...)`/`find:`).
You can read more about "package discovery" and "data files" on setuptools
documentation page.
!!
check.warn(importable)
copying tflite_support\metadata_schema.fbs -> build\lib.win-amd64-cpython-310\tflite_support
creating build\lib.win-amd64-cpython-310\tflite_support\flatbuffers
copying tflite_support\flatbuffers\__init__.py -> build\lib.win-amd64-cpython-310\tflite_support\flatbuffers
copying tflite_support\flatbuffers\builder.py -> build\lib.win-amd64-cpython-310\tflite_support\flatbuffers
copying tflite_support\flatbuffers\compat.py -> build\lib.win-amd64-cpython-310\tflite_support\flatbuffers
copying tflite_support\flatbuffers\encode.py -> build\lib.win-amd64-cpython-310\tflite_support\flatbuffers
copying tflite_support\flatbuffers\number_types.py -> build\lib.win-amd64-cpython-310\tflite_support\flatbuffers
copying tflite_support\flatbuffers\packer.py -> build\lib.win-amd64-cpython-310\tflite_support\flatbuffers
copying tflite_support\flatbuffers\table.py -> build\lib.win-amd64-cpython-310\tflite_support\flatbuffers
copying tflite_support\flatbuffers\util.py -> build\lib.win-amd64-cpython-310\tflite_support\flatbuffers
running build_ext
building '_pywrap_codegen' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> tflite-support
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.这是因为 tflite-support 没有官方的 Windows 发行版,因此在 Windows 系统上需要自行编译
从输出可以看到:error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/
即本地没有 C++编译器,因此我们只需安装 C++编译器即可:https://visualstudio.microsoft.com/zh-hant/visual-cpp-build-tools
在安装时只需要勾选 使用 C++的桌面开发 ,无需勾选其余项目
在安装后使用命令 pip install tflite-support 重新安装即可
推荐:Vultr 云服务器 1C1G 月付 5 刀 使用优惠码 VULTRMATCH 充多少送多少 支持支付宝/PayPal
推荐:ColoCrossing 美国 VPS 1C1G 年付$10.99 USD 支持支付宝/PayPal 常规 VPS 套餐使用优惠码 CNY5824 循环 58%折扣 1C1G 折后月付$1.66 USD