Tensorflow, ImportError: DLL load failed 에러

    (python) E:\Project\steel\python>pip install tensorflow
    Collecting tensorflow
      Downloading tensorflow-2.1.0-cp37-cp37m-win_amd64.whl (355.8 MB)
         |████████████████████████████████| 355.8 MB 22 kB/s
    Collecting tensorflow-estimator<2.2.0,>=2.1.0rc0
      Downloading tensorflow_estimator-2.1.0-py2.py3-none-any.whl (448 kB)
         |████████████████████████████████| 448 kB 2.2 MB/s
    Collecting absl-py>=0.7.0
      Downloading absl-py-0.9.0.tar.gz (104 kB)
         |████████████████████████████████| 104 kB 2.2 MB/s
    Requirement already satisfied: wheel>=0.26; python_version >= "3" in c:\anaconda3\envs\python\lib\site-packages (from tensorflow) (0.34.2)
    Collecting scipy==1.4.1; python_version >= "3"
      Downloading scipy-1.4.1-cp37-cp37m-win_amd64.whl (30.9 MB)
         |████████████████████████████████| 30.9 MB 288 kB/s
    Collecting gast==0.2.2
      Downloading gast-0.2.2.tar.gz (10 kB)
    Collecting astor>=0.6.0
      Downloading astor-0.8.1-py2.py3-none-any.whl (27 kB)
    Collecting numpy<2.0,>=1.16.0
      Downloading numpy-1.18.2-cp37-cp37m-win_amd64.whl (12.8 MB)
         |████████████████████████████████| 12.8 MB 1.3 MB/s
    Collecting termcolor>=1.1.0
      Downloading termcolor-1.1.0.tar.gz (3.9 kB)
    Collecting google-pasta>=0.1.6
      Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)
         |████████████████████████████████| 57 kB 387 kB/s
    Collecting opt-einsum>=2.3.2
      Downloading opt_einsum-3.2.0-py3-none-any.whl (63 kB)
         |████████████████████████████████| 63 kB 764 kB/s
    Collecting wrapt>=1.11.1
      Downloading wrapt-1.12.1.tar.gz (27 kB)
    Collecting six>=1.12.0
      Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
    Collecting protobuf>=3.8.0
      Downloading protobuf-3.11.3-cp37-cp37m-win_amd64.whl (1.0 MB)
         |████████████████████████████████| 1.0 MB 1.6 MB/s
    Collecting tensorboard<2.2.0,>=2.1.0
      Downloading tensorboard-2.1.1-py3-none-any.whl (3.8 MB)
         |████████████████████████████████| 3.8 MB 372 kB/s
    Collecting keras-preprocessing>=1.1.0
      Downloading Keras_Preprocessing-1.1.0-py2.py3-none-any.whl (41 kB)
         |████████████████████████████████| 41 kB 263 kB/s
    Collecting grpcio>=1.8.6
      Downloading grpcio-1.27.2-cp37-cp37m-win_amd64.whl (1.9 MB)
         |████████████████████████████████| 1.9 MB 2.2 MB/s
    Collecting keras-applications>=1.0.8
      Downloading Keras_Applications-1.0.8-py3-none-any.whl (50 kB)
         |████████████████████████████████| 50 kB 1.6 MB/s
    Requirement already satisfied: setuptools in c:\anaconda3\envs\python\lib\site-packages (from protobuf>=3.8.0->tensorflow) (46.0.0.post20200309)
    Collecting requests<3,>=2.21.0
      Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
         |████████████████████████████████| 58 kB 1.6 MB/s
    Collecting markdown>=2.6.8
      Downloading Markdown-3.2.1-py2.py3-none-any.whl (88 kB)
         |████████████████████████████████| 88 kB 1.7 MB/s
    Collecting google-auth<2,>=1.6.3
      Downloading google_auth-1.11.3-py2.py3-none-any.whl (76 kB)
         |████████████████████████████████| 76 kB 1.3 MB/s
    Collecting werkzeug>=0.11.15
      Downloading Werkzeug-1.0.0-py2.py3-none-any.whl (298 kB)
         |████████████████████████████████| 298 kB 2.2 MB/s
    Collecting google-auth-oauthlib<0.5,>=0.4.1
      Downloading google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)
    Collecting h5py
      Downloading h5py-2.10.0-cp37-cp37m-win_amd64.whl (2.5 MB)
         |████████████████████████████████| 2.5 MB 2.2 MB/s
    Requirement already satisfied: certifi>=2017.4.17 in c:\anaconda3\envs\python\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow) (2019.11.28)
    Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
      Downloading urllib3-1.25.8-py2.py3-none-any.whl (125 kB)
         |████████████████████████████████| 125 kB 2.2 MB/s
    Collecting chardet<4,>=3.0.2
      Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
         |████████████████████████████████| 133 kB 2.2 MB/s
    Collecting idna<3,>=2.5
      Downloading idna-2.9-py2.py3-none-any.whl (58 kB)
         |████████████████████████████████| 58 kB 1.0 MB/s
    Collecting pyasn1-modules>=0.2.1
      Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
         |████████████████████████████████| 155 kB 2.2 MB/s
    Collecting cachetools<5.0,>=2.0.0
      Downloading cachetools-4.0.0-py3-none-any.whl (10 kB)
    Collecting rsa<4.1,>=3.1.4
      Downloading rsa-4.0-py2.py3-none-any.whl (38 kB)
    Collecting requests-oauthlib>=0.7.0
      Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
    Collecting pyasn1<0.5.0,>=0.4.6
      Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
         |████████████████████████████████| 77 kB 1.3 MB/s
    Collecting oauthlib>=3.0.0
      Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
         |████████████████████████████████| 147 kB 2.2 MB/s
    Building wheels for collected packages: absl-py, gast, termcolor, wrapt
      Building wheel for absl-py (setup.py) ... done
      Created wheel for absl-py: filename=absl_py-0.9.0-py3-none-any.whl size=121935 sha256=08b574cbdf5613438fc5c166fe5483011365e17e2c22ea21b2011f719a385d71
      Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\cc\af\1a\498a24d0730ef484019e007bb9e8cef3ac00311a672c049a3e
      Building wheel for gast (setup.py) ... done
      Created wheel for gast: filename=gast-0.2.2-py3-none-any.whl size=7547 sha256=7bb6d3a94054e6f2505ec9d5a226605430c0215eb2a587ec99154fddcefd97a5
      Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\21\7f\02\420f32a803f7d0967b48dd823da3f558c5166991bfd204eef3
      Building wheel for termcolor (setup.py) ... done
      Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4835 sha256=a427b45ab2bdc065fd3057057c587f510f4136c080dc114897490be87f87c3c9
      Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\3f\e3\ec\8a8336ff196023622fbcb36de0c5a5c218cbb24111d1d4c7f2
      Building wheel for wrapt (setup.py) ... done
      Created wheel for wrapt: filename=wrapt-1.12.1-cp37-cp37m-win_amd64.whl size=33377 sha256=0875e8135bb17ba5e689daf315c0df7ab51e47645db985ed31152dba53884994
      Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\62\76\4c\aa25851149f3f6d9785f6c869387ad82b3fd37582fa8147ac6
    Successfully built absl-py gast termcolor wrapt
    Installing collected packages: tensorflow-estimator, six, absl-py, numpy, scipy, gast, astor, termcolor, google-pasta, opt-einsum, wrapt, protobuf, urllib3, chardet, idna, requests, markdown, grpcio, pyasn1, pyasn1-modules, cachetools, rsa, google-auth, werkzeug, oaut
    Installing collected packages: tensorflow-estimator, six, absl-py, numpy, scipy, gast, astor, termcolor, google-pasta, opt-einsum, wrapt, protobuf, urllib3, chardet, idna, re
    hlib, requests-oauthlib, google-auth-oauthlib, tensorboard, keras-preprocessing, h5py, keras-applications, tensorflow
    Successfully installed absl-py-0.9.0 astor-0.8.1 cachetools-4.0.0 chardet-3.0.4 gast-0.2.2 google-auth-1.11.3 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.27.2 h5py
    2 oauthlib-3.1.0 opt-einsum-3.2.0 protobuf-3.11.3 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.23.0 requests-oauthlib-1.3.0 rsa-4.0 scipy-1.4.1 six-1.14.0 tensorboard-2.1.1 t
    -1.12.1

    다음과 같이 pip install tensorflow로 텐서플로우 2.1.0 버전을 설치하였다. 이상이 없이 정상적으로 설치가 되어서 텐서플로우 2 버전을 테스트 해보려고 다음과 같이 코드를 입력 하였는데

     

    import numpy as np
    import tensorflow as tf
    
    print(tf.__version__)

     

     

    DLL 관련한 에러가 발생하였다.

    C:\Anaconda3\envs\python\python.exe E:/Project/steel/python/tensorflow_2.py Traceback (most recent call last): File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "C:\Anaconda3\envs\python\lib\imp.py", line 242, in load_module return load_dynamic(name, filename, file) File "C:\Anaconda3\envs\python\lib\imp.py", line 342, in load_dynamic return _load(spec) ImportError: DLL load failed: 지정된 모듈을 찾을 수 없습니다. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "E:/Project/steel/python/tensorflow_2.py", line 2, in import tensorflow as tf File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow\__init__.py", line 101, in from tensorflow_core import * File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow_core\__init__.py", line 40, in from tensorflow.python.tools import module_util as _module_util File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__ module = self._load() File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow\__init__.py", line 44, in _load module = _importlib.import_module(self.__name__) File "C:\Anaconda3\envs\python\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in from tensorflow.python import pywrap_tensorflow File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\Anaconda3\envs\python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "C:\Anaconda3\envs\python\lib\imp.py", line 242, in load_module return load_dynamic(name, filename, file) File "C:\Anaconda3\envs\python\lib\imp.py", line 342, in load_dynamic return _load(spec) ImportError: DLL load failed: 지정된 모듈을 찾을 수 없습니다. 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. Process finished with exit code 1 

    구글링을 해보니 텐서플로우가 2.1 버전에서 충돌나는 문제로 보이며, 버전을 2.0 버전으로 설치해서 해결이 되었다는 사례가 있어서, 텐서플로우를 삭제하고 설치하기로 하였다.

     

    (python) E:\Project\steel\python>pip uninstall tensorflow
    Found existing installation: tensorflow 2.1.0
    Uninstalling tensorflow-2.1.0:
      Would remove:
        c:\anaconda3\envs\python\lib\site-packages\tensorflow-2.1.0.dist-info\*
        c:\anaconda3\envs\python\lib\site-packages\tensorflow\*
        c:\anaconda3\envs\python\lib\site-packages\tensorflow_core\*
        c:\anaconda3\envs\python\scripts\estimator_ckpt_converter.exe
        c:\anaconda3\envs\python\scripts\saved_model_cli.exe
        c:\anaconda3\envs\python\scripts\tensorboard.exe
        c:\anaconda3\envs\python\scripts\tf_upgrade_v2.exe
        c:\anaconda3\envs\python\scripts\tflite_convert.exe
        c:\anaconda3\envs\python\scripts\toco.exe
        c:\anaconda3\envs\python\scripts\toco_from_protos.exe
    Proceed (y/n)? y
      Successfully uninstalled tensorflow-2.1.0

    pip uninstall tensorflow로 2.1 버전을 삭제하였고...(설치할때는 드럽게 오래 걸리더니만, 삭제는 순삭인듯...)

     

    pip install tensorflow==2.0

    위와 같이 pip 명령어를 지정하여 2.0 버전으로 재설치를 진행하였다.

     

    (python) E:\Project\steel\python>pip install tensorflow==2.0
    Collecting tensorflow==2.0
      Downloading tensorflow-2.0.0-cp37-cp37m-win_amd64.whl (48.1 MB)
         |████████████████████████████████| 48.1 MB 1.6 MB/s
    Requirement already satisfied: google-pasta>=0.1.6 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (0.2.0)
    Requirement already satisfied: keras-applications>=1.0.8 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (1.0.8)
    Collecting tensorboard<2.1.0,>=2.0.0
      Downloading tensorboard-2.0.2-py3-none-any.whl (3.8 MB)
         |████████████████████████████████| 3.8 MB 1.1 MB/s
    Requirement already satisfied: numpy<2.0,>=1.16.0 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (1.18.2)
    Requirement already satisfied: absl-py>=0.7.0 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (0.9.0)
    Requirement already satisfied: opt-einsum>=2.3.2 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (3.2.0)
    Requirement already satisfied: grpcio>=1.8.6 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (1.27.2)
    Requirement already satisfied: termcolor>=1.1.0 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (1.1.0)
    Requirement already satisfied: keras-preprocessing>=1.0.5 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (1.1.0)
    Requirement already satisfied: wrapt>=1.11.1 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (1.12.1)
    Requirement already satisfied: gast==0.2.2 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (0.2.2)
    Requirement already satisfied: protobuf>=3.6.1 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (3.11.3)
    Requirement already satisfied: six>=1.10.0 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (1.14.0)
    Collecting tensorflow-estimator<2.1.0,>=2.0.0
      Downloading tensorflow_estimator-2.0.1-py2.py3-none-any.whl (449 kB)
         |████████████████████████████████| 449 kB 3.3 MB/s
    Requirement already satisfied: astor>=0.6.0 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (0.8.1)
    Requirement already satisfied: wheel>=0.26 in c:\anaconda3\envs\python\lib\site-packages (from tensorflow==2.0) (0.34.2)
    Requirement already satisfied: h5py in c:\anaconda3\envs\python\lib\site-packages (from keras-applications>=1.0.8->tensorflow==2.0) (2.10.0)
    Requirement already satisfied: google-auth<2,>=1.6.3 in c:\anaconda3\envs\python\lib\site-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (1.11.3)
    Requirement already satisfied: requests<3,>=2.21.0 in c:\anaconda3\envs\python\lib\site-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (2.23.0)
    Requirement already satisfied: werkzeug>=0.11.15 in c:\anaconda3\envs\python\lib\site-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (1.0.0)
    Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in c:\anaconda3\envs\python\lib\site-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (0.4.1)
    Requirement already satisfied: setuptools>=41.0.0 in c:\anaconda3\envs\python\lib\site-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (46.0.0.post20200309)
    Requirement already satisfied: markdown>=2.6.8 in c:\anaconda3\envs\python\lib\site-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (3.2.1)
    Requirement already satisfied: cachetools<5.0,>=2.0.0 in c:\anaconda3\envs\python\lib\site-packages (from google-auth<2,>=1.6.3->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (4.0.0)
    Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\anaconda3\envs\python\lib\site-packages (from google-auth<2,>=1.6.3->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (0.2.8)
    Requirement already satisfied: rsa<4.1,>=3.1.4 in c:\anaconda3\envs\python\lib\site-packages (from google-auth<2,>=1.6.3->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (4.0)
    Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\anaconda3\envs\python\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (1.25.8)
    Requirement already satisfied: chardet<4,>=3.0.2 in c:\anaconda3\envs\python\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (3.0.4)
    Requirement already satisfied: idna<3,>=2.5 in c:\anaconda3\envs\python\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (2.9)
    Requirement already satisfied: certifi>=2017.4.17 in c:\anaconda3\envs\python\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (2019.11.28)
    Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\anaconda3\envs\python\lib\site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (1.3.0)
    Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in c:\anaconda3\envs\python\lib\site-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (0.4.8)
    Requirement already satisfied: oauthlib>=3.0.0 in c:\anaconda3\envs\python\lib\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.1.0,>=2.0.0->tensorflow==2.0) (3.1.0)
    Installing collected packages: tensorboard, tensorflow-estimator, tensorflow
      Attempting uninstall: tensorboard
        Found existing installation: tensorboard 2.1.1
        Uninstalling tensorboard-2.1.1:
          Successfully uninstalled tensorboard-2.1.1
      Attempting uninstall: tensorflow-estimator
        Found existing installation: tensorflow-estimator 2.1.0
        Uninstalling tensorflow-estimator-2.1.0:
          Successfully uninstalled tensorflow-estimator-2.1.0
    Successfully installed tensorboard-2.0.2 tensorflow-2.0.0 tensorflow-estimator-2.0.1

    설치가 마무리되어, 다시 코드를 실행하였다. 결과는 이상없이 2.0.0 이 출력되면서 성공되었다. 2.1 버전이 현재 내 버전과 뭔가 잘 안 맞는 것 같은데 파이썬은 이것이 진짜 문제인 것 같다.

     

    반응형

    댓글

    Designed by JB FACTORY