安装Keras时遇到问题

时间:2020-10-11 16:10:49

标签: python tensorflow keras import anaconda

我尝试了几件事,并且在尝试将keras安装到Python时遇到很多困难。

  1. 首先,我尝试通过尝试使用以下命令将其导入我的Jupyter Notebook:
from keras.models import Sequential
from keras.layers import Dense

这导致了以下错误:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-17-b9e2c8277ae4> in <module>
----> 1 from keras.models import Sequential
      2 from keras.layers import Dense

ModuleNotFoundError: No module named 'keras'
  1. 然后,我尝试导入tensorflow。
from tensorflow.keras.models import Sequential 
from tensorflow.keras.layers import Dense,Dropout,Activation, Flatten, Conv2D, MaxPooling2D 

这也不起作用,因为我收到了和以前类似的错误。

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-18-9d4e366b5092> in <module>
----> 1 from tensorflow.keras.models import Sequential #used for model building
      2 from tensorflow.keras.layers import Dense,Dropout,Activation, Flatten, Conv2D, MaxPooling2D #used for model building

ModuleNotFoundError: No module named 'tensorflow'
  1. 我终于尝试通过Anaconda使用该终端。这也失败了。
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

我有Python 3.8,但显然keras需要python[version='>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0']。我该怎么办才能导入keras?

1 个答案:

答案 0 :(得分:1)

无论出于何种原因,kerastensorflow在Python 3.8中均无法很好地工作。我会尝试恢复到Python 3.7。