我尝试了几件事,并且在尝试将keras安装到Python时遇到很多困难。
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'
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'
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?
答案 0 :(得分:1)
无论出于何种原因,keras
和tensorflow
在Python 3.8中均无法很好地工作。我会尝试恢复到Python 3.7。