无法导入ktrain,因为import terror:导入defs时DLL加载失败:无法找到指定的过程



下面是我在尝试import ktrain时得到的错误。

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~AppDataLocalTemp/ipykernel_16480/1394454297.py in <module>
1 import numpy as np
----> 2 import ktrain
3 from ktrain import text
4 import tensorflow as tf
5 import pandas as pd
~anaconda3envstfgpulibsite-packagesktrain__init__.py in <module>
1 from .version import __version__
2 from . import imports as I
----> 3 from .core import ArrayLearner, GenLearner, get_predictor, load_predictor, release_gpu_memory
4 from .vision.learner import ImageClassLearner
5 from .text.learner import BERTTextClassLearner, TransformerTextClassLearner
~anaconda3envstfgpulibsite-packagesktraincore.py in <module>
9 from .vision.preprocessor import ImagePreprocessor
10 from .vision.predictor import ImagePredictor
---> 11 from .text.preprocessor import TextPreprocessor, BERTPreprocessor, TransformersPreprocessor
12 from .text.predictor import TextPredictor
13 from .text.ner.predictor import NERPredictor
~anaconda3envstfgpulibsite-packagesktraintext__init__.py in <module>
----> 1 from .models import print_text_classifiers, print_text_regression_models, text_classifier, text_regression_model
2 from .data import texts_from_folder, texts_from_csv, texts_from_df,  texts_from_array
3 from .ner.data import entities_from_gmb, entities_from_conll2003, entities_from_txt, entities_from_df, entities_from_array
4 from .ner.models import sequence_tagger, print_sequence_taggers
5 from .eda import get_topic_model
~anaconda3envstfgpulibsite-packagesktraintextmodels.py in <module>
1 from ..imports import *
2 from .. import utils as U
----> 3 from . import preprocessor as tpp
4 
5 
~anaconda3envstfgpulibsite-packagesktraintextpreprocessor.py in <module>
5 from . import textutils as TU
6 
----> 7 from transformers import AutoConfig, TFAutoModelForSequenceClassification, AutoTokenizer, TFAutoModel
8 
9 
~anaconda3envstfgpulibsite-packagestransformers__init__.py in __getattr__(self, name)
2188             if name == "__version__":
2189                 return __version__
-> 2190             return super().__getattr__(name)
2191 
2192     sys.modules[__name__] = _LazyModule(__name__, _import_structure)
~anaconda3envstfgpulibsite-packagestransformersfile_utils.py in __getattr__(self, name)
1493         elif name in self._class_to_module.keys():
1494             module = self._get_module(self._class_to_module[name])
-> 1495             value = getattr(module, name)
1496         else:
1497             raise AttributeError(f"module {self.__name__} has no attribute {name}")
~anaconda3envstfgpulibsite-packagestransformersfile_utils.py in __getattr__(self, name)
1492             value = self._get_module(name)
1493         elif name in self._class_to_module.keys():
-> 1494             module = self._get_module(self._class_to_module[name])
1495             value = getattr(module, name)
1496         else:
~anaconda3envstfgpulibsite-packagestransformersmodelsauto__init__.py in _get_module(self, module_name)
158 
159         def _get_module(self, module_name: str):
--> 160             return importlib.import_module("." + module_name, self.__name__)
161 
162     sys.modules[__name__] = _LazyModule(__name__, _import_structure)
~anaconda3envstfgpulibimportlib__init__.py in import_module(name, package)
125                 break
126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
128 
129 
~anaconda3envstfgpulibsite-packagestransformersmodelsautomodeling_tf_auto.py in <module>
24 
25 # Add modeling imports here
---> 26 from ..albert.modeling_tf_albert import (
27     TFAlbertForMaskedLM,
28     TFAlbertForMultipleChoice,
~anaconda3envstfgpulibsite-packagestransformersmodelsalbertmodeling_tf_albert.py in <module>
40     TFTokenClassifierOutput,
41 )
---> 42 from ...modeling_tf_utils import (
43     TFMaskedLanguageModelingLoss,
44     TFMultipleChoiceLoss,
~anaconda3envstfgpulibsite-packagestransformersmodeling_tf_utils.py in <module>
23 from typing import Dict, List, Optional, Union
24 
---> 25 import h5py
26 import numpy as np
27 import tensorflow as tf
~anaconda3envstfgpulibsite-packagesh5py__init__.py in <module>
31         raise
32 
---> 33 from . import version
34 
35 if version.hdf5_version_tuple != version.hdf5_built_version_tuple:
~anaconda3envstfgpulibsite-packagesh5pyversion.py in <module>
13 
14 from collections import namedtuple
---> 15 from . import h5 as _h5
16 import sys
17 import numpy
h5pyh5.pyx in init h5py.h5()
ImportError: DLL load failed while importing defs: The specified procedure could not be found.

我已经在互联网和YouTube上搜索了许多可能的解决方案,但仍然无法解决它。

这是我的电脑规格环境特征:操作系统:Windows 10Python版本:3.9.0tensorflow: 2.5.0tensorflow-gpu: 2.5.0GPU: RTX 2080

对于在导入h5py时遇到相同问题的人(我在Windows上使用anaconda并试图安装h5py),在我的情况下,问题通过以下方式解决:

  1. 将所有丢失的dll从HDF5复制到h5py的目录
  2. 通过conda删除并安装h5py:3.5并使用pip升级到3.6(我猜conda构建有问题)

相关内容

  • 没有找到相关文章

最新更新