李小白随笔
系统:win11
最近在学习yolov5项目工程,需要安装一个包tflite-support,
我是直接用的pip install tflite-support,就会报下面的错
pip install tflite_support
Collecting tflite_support
Using cached tflite-support-0.1.0a1.tar.gz (390 kB)
Preparing metadata (setup.py) ... done
Collecting pybind11>=2.4 (from tflite_support)
Using cached pybind11-2.13.6-py3-none-any.whl.metadata (9.5 kB)
Requirement already satisfied: absl-py>=0.7.0 in d:\anaconda\envs\yolo\lib\site-packages (from tflite_support) (2.1.0)
Requirement already satisfied: numpy in d:\anaconda\envs\yolo\lib\site-packages (from tflite_support) (1.26.4)
Using cached pybind11-2.13.6-py3-none-any.whl (243 kB)
Building wheels for collected packages: tflite_support
Building wheel for tflite_support (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [82 lines of output]
D:\Anaconda\envs\yolo\lib\site-packages\setuptools\__init__.py:94: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!
********************************************************************************
Requirements should be satisfied by a PEP 517 installer.
If you are using pip, you can try `pip install --use-pep517`.
********************************************************************************
!!
dist.fetch_build_eggs(dist.setup_requires)
running bdist_wheel
running build
running build_py
creating build\lib.win-amd64-cpython-310\tflite_support
copying tflite_support\codegen.py -> build\lib.win-amd64-cpython-310\tflite_support
copying tflite_support\metadata.py -> build\lib.win-amd64-cpython-310\tflite_support
copying tflite_support\metadata_schema_py_generated.py -> build\lib.win-amd64-cpython-310\tflite_support
copying tflite_support\schema_py_generated.py -> build\lib.win-amd64-cpython-310\tflite_support
copying tflite_support\__init__.py -> build\lib.win-amd64-cpython-310\tflite_support
running egg_info
writing tflite_support.egg-info\PKG-INFO
writing dependency_links to tflite_support.egg-info\dependency_links.txt
writing entry points to tflite_support.egg-info\entry_points.txt
writing requirements to tflite_support.egg-info\requires.txt
writing top-level names to tflite_support.egg-info\top_level.txt
reading manifest file 'tflite_support.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'tflite_support.egg-info\SOURCES.txt'
D:\Anaconda\envs\yolo\lib\site-packages\setuptools\command\build_py.py:218: _Warning: Package 'tflite_support.flatbuffers' is absent from the `packages` configuration.
!!
********************************************************************************
############################
# Package would be ignored #
############################
Python recognizes 'tflite_support.flatbuffers' as an importable package[^1],
but it is absent from setuptools' `packages` configuration.
This leads to an ambiguous overall configuration. If you want to distribute this
package, please make sure that 'tflite_support.flatbuffers' is explicitly added
to the `packages` configuration field.
Alternatively, you can also rely on setuptools' discovery methods
(for example by using `find_namespace_packages(...)`/`find_namespace:`
instead of `find_packages(...)`/`find:`).
You can read more about "package discovery" on setuptools documentation page:
- https://setuptools.pypa.io/en/latest/userguide/package_discovery.html
If you don't want 'tflite_support.flatbuffers' to be distributed and are
already explicitly excluding 'tflite_support.flatbuffers' via
`find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
you can try to use `exclude_package_data`, or `include-package-data=False` in
combination with a more fine grained `package-data` configuration.
You can read more about "package data files" on setuptools documentation page:
- https://setuptools.pypa.io/en/latest/userguide/datafiles.html
[^1]: For Python, any directory (with suitable naming) can be imported,
even if it does not contain any `.py` files.
On the other hand, currently there is no concept of package data
directory, all directories are treated like packages.
********************************************************************************
!!
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: Failed building wheel for tflite_support
Running setup.py clean for tflite_support
ERROR: Operation cancelled by user
用conda install tflite-support也不行
原因:
1、在构建 tflite-support包的 wheel 文件(一种方便安装和分发 Python 包的格式)时,需要编译一些 C++ 扩展模块,而这个过程要求系统安装了 Microsoft Visual C++ 14.0
或更高版本。从输出的错误信息 “error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": Microsoft C++ Build Tools - Visual Studio” 可以明确看出是缺少这个编译环境导致的失败
2、官方没有给Windows的.whl文件。点击tflite-support · PyPI,可以看到里面只有不同python版本的linux和mac系统的.whl文件
解决办法:
安装C++编译器Visual Studio,随后重启电脑,使用pip install tflite-support命令,就可以安装成功