keris2020 / hackathon

10 stars 7 forks source link

import keras 오류 #20

Closed kdh7979 closed 4 years ago

kdh7979 commented 4 years ago

주피터 노트북에서 import keras를 하면 오류가 뜹니다. keras와 tensorflow 모두 pip install을 이용해서 다운 받았고 tensorflow 버전은 2.3.1이고 keras는 2.4.3입니다.

<오류 코드> ImportError Traceback (most recent call last) ~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in 63 try: ---> 64 from tensorflow.python._pywrap_tensorflow_internal import * 65 # This try catch logic is because there is no bazel equivalent for py_extension.

ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 지정된 모듈을 찾을 수 없습니다.

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last) ~\anaconda3\lib\site-packages\keras__init__.py in 2 try: ----> 3 from tensorflow.keras.layers.experimental.preprocessing import RandomRotation 4 except ImportError:

~\anaconda3\lib\site-packages\tensorflow__init__.py in 40 ---> 41 from tensorflow.python.tools import module_util as _module_util 42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader

~\anaconda3\lib\site-packages\tensorflow\python__init__.py in 39 ---> 40 from tensorflow.python.eager import context 41

~\anaconda3\lib\site-packages\tensorflow\python\eager\context.py in 34 from tensorflow.core.protobuf import rewriter_config_pb2 ---> 35 from tensorflow.python import pywrap_tfe 36 from tensorflow.python import tf2

~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py in 27 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import ---> 28 from tensorflow.python import pywrap_tensorflow 29 from tensorflow.python._pywrap_tfe import *

~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in 82 above this error message when asking for help.""" % traceback.format_exc() ---> 83 raise ImportError(msg) 84

ImportError: Traceback (most recent call last): File "C:\Users\kimdo\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 지정된 모듈을 찾을 수 없습니다.

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)

in ----> 1 import keras ~\anaconda3\lib\site-packages\keras\__init__.py in 3 from tensorflow.keras.layers.experimental.preprocessing import RandomRotation 4 except ImportError: ----> 5 raise ImportError( 6 'Keras requires TensorFlow 2.2 or higher. ' 7 'Install TensorFlow via `pip install tensorflow`') ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`
taeseug commented 4 years ago

keras와 tensorflow 설치시 필요한 모듈이 정상적으로 설치 되지 않은것 같습니다. pip uninstall 을 이용해 삭제후 다시 설치 해 주세요
재설치시' conda install tensorflow '를 이용해 설치 해주세요 . 그러면 anaconda 에서 필요한 요구사항을 맞추어서 갗이 설치해 줍니다. 만일 tensorflow gpu 버젼을 설치하려면 " conda install tensorflow-gpu " 하시면 됩니다.
그리고 tensorflow 2.0 버젼 이후 부터는 keras 를 포함하고 있어 따로 import keras 를 하지 않고 from tensorflow.keras.datasets import mnist 이런식으로 사용합니다.

kdh7979 commented 4 years ago

해결 법을 찾았습니다. https://needneo.tistory.com/47 위 사이트를 참조하세요.