导入Keras时出现RuntimeError吗?

时间:2019-10-23 20:19:23

标签: python tensorflow keras

我正在尝试使用Keras和Python做一些新手级别的教程,但是我无法超越keras模块的导入。我正在使用新的virtualenv在Python 3.7.3中工作(在Mac / no GPU上)。这是我的pip list

Package              Version
-------------------- -------
absl-py              0.8.1  
astor                0.8.0  
gast                 0.2.2  
google-pasta         0.1.7  
grpcio               1.24.3 
h5py                 2.10.0 
Keras                2.3.1  
Keras-Applications   1.0.8  
Keras-Preprocessing  1.1.0  
Markdown             3.1.1  
numpy                1.17.3 
opt-einsum           3.1.0  
pip                  19.3.1 
protobuf             3.10.0 
PyYAML               5.1.2  
scipy                1.3.1  
setuptools           41.4.0 
six                  1.12.0 
tensorboard          2.0.0  
tensorflow           2.0.0  
tensorflow-estimator 2.0.1  
termcolor            1.1.0  
Werkzeug             0.16.0 
wheel                0.33.6 
wrapt                1.11.2 

这是错误:

(venv) $ python -c "import keras"
Using TensorFlow backend.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/me/KerasTutorial/venv/lib/python3.7/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "Users/me/KerasTutorial/venv/lib/python3.7/site-packages/keras/utils/__init__.py", line 6, in <module>
    from . import conv_utils

...


  File "Users/me/KerasTutorial/venv/lib/python3.7/linecache.py", line 48, in getlines
    for mod in sys.modules.values():
RuntimeError: dictionary changed size during iteration

1 个答案:

答案 0 :(得分:0)

发现了问题。显然,tensorflow尚不支持Python 3.7。我尝试使用Python 3.6.4,一切正常。