尝试在同一文件中同时导入tensorflow
和tables
会导致错误。错误取决于它们的导入顺序。我该如何解决该错误?
tables
然后tensorflow
:
>>> import tables
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\__init__.py", line 83, in <module>
from tensorflow.python import keras
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\keras\__init__.py", line 26, in <module>
from tensorflow.python.keras import activations
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\keras\activations.py", line 24, in <module>
from tensorflow.python.keras.utils.generic_utils import deserialize_keras_object
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\keras\utils\__init__.py", line 39, in <module>
from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\keras\utils\multi_gpu_utils.py", line 22, in <module>
from tensorflow.python.keras.engine.training import Model
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\keras\engine\training.py", line 40, in <module>
from tensorflow.python.keras.engine import network
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\keras\engine\network.py", line 39, in <module>
from tensorflow.python.keras import saving
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\keras\saving\__init__.py", line 20, in <module>
from tensorflow.python.keras.saving.hdf5_format import load_attributes_from_hdf5_group
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\keras\saving\hdf5_format.py", line 38, in <module>
import h5py
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\h5py\__init__.py", line 36, in <module>
from ._conv import register_converters as _register_converters
File "h5py\h5r.pxd", line 21, in init h5py._conv
File "h5py\h5r.pyx", line 145, in init h5py.h5r
AttributeError: type object 'h5py.h5r.Reference' has no attribute '__reduce_cython__'
tensorflow
然后tables
:
>>> import tensorflow
>>> import tables
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\tables\__init__.py", line 93, in <module>
from .utilsextension import (
ImportError: DLL load failed: The specified procedure could not be found.
我正在Windows 10上运行它。Python和两个软件包的版本信息:
C:\>python --version
Python 3.5.4
C:\>pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.14.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: c:\users\user\appdata\local\programs\python\python35\lib\site-packages
Requires: astor, gast, grpcio, wrapt, wheel, absl-py, protobuf, six, termcolor, keras-preprocessing, google-pasta, keras-applications, numpy, tensorflow-estimator, tensorboard
Required-by:
C:\>pip show tables
Name: tables
Version: 3.5.2
Summary: Hierarchical datasets for Python
Home-page: http://www.pytables.org/
Author: PyTables maintainers
Author-email: pytables@pytables.org
License: BSD 2-Clause
Location: c:\users\user\appdata\local\programs\python\python35\lib\site-packages
Requires: numexpr, six, numpy, mock
Required-by: