无法导入tflitesupport包。接收错误“DLL加载失败:找不到指定的模块”

2024-09-28 22:25:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在尝试在我的Anaconda环境中安装tflite支持包。以下是我遵循的步骤:

  • 使用conda create --name test_env python==3.7创建了一个新的python环境
  • 使用conda install tensorflow安装tensorflow(因为pip安装在我的电脑上出现导入错误)
  • 然后使用pip install tflite-support安装tflite支持包(conda安装抛出PackagesNotFoundError错误)

以下代码段可用于重现错误:

import tensorflow as tf
from tflite_support import flatbuffers
from tflite_support import metadata as _metadata
from tflite_support import metadata_schema_py_generated as _metadata_fb

这会引发以下错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-37cdba048740> in <module>
----> 1 from tflite_support import flatbuffers
      2 from tflite_support import metadata as _metadata
      3 from tflite_support import metadata_schema_py_generated as _metadata_fb

c:\programdata\anaconda3\envs\testx\lib\site-packages\tflite_support\__init__.py in <module>
     28 
     29 import flatbuffers as _flatbuffers
---> 30 from tensorflow_lite_support.metadata import metadata as _metadata
     31 from tensorflow_lite_support.metadata import metadata_schema_py_generated as _metadata_schema_py_generated
     32 from tensorflow_lite_support.metadata import schema_py_generated as _schema_py_generated

c:\programdata\anaconda3\envs\testx\lib\site-packages\tensorflow_lite_support\metadata\metadata.py in <module>
     32 from tensorflow_lite_support.metadata import metadata_schema_py_generated as _metadata_fb
     33 from tensorflow_lite_support.metadata import schema_py_generated as _schema_fb
---> 34 from tensorflow_lite_support.metadata.cc.python import _pywrap_metadata_version
     35 from tensorflow_lite_support.metadata.flatbuffers_lib import _pywrap_flatbuffers
     36 

ImportError: DLL load failed: The specified module could not be found.

我尝试了不同版本的python、tensorflow&;tflite支持,但每次都会出现相同的错误。提前谢谢


Tags: frompyimportsupportfbschematensorflowas