본문 바로가기
Machine Learning | Deep Learning

[개발환경]머신러닝&딥러닝을 위한 아나콘다 주피터 환경 세팅

by 다봄이 2020. 8. 18.

Trouble Shooting

  • ImportError: DLL load failed when trying import ssl
  • conda install tensorflow vs pip install tensorflow

ssl import error

(base) C:\Users\User>jupyter notebook
Traceback (most recent call last):
File "C:\Users\User\anaconda3\envs\tf2\Scripts\jupyter-notebook-script.py", line 6, in <module>
    from notebook.notebookapp import main
File "C:\Users\User\anaconda3\envs\tf2\lib\site-packages\notebook\notebookapp.py", line 66, in <module>
    from tornado import httpserver
File "C:\Users\User\anaconda3\envs\tf2\lib\site-packages\tornado\httpserver.py", line 29, in <module>
    import ssl
File "C:\Users\User\anaconda3\envs\tf2\lib\ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: DLL load failed: 지정된 프로시저를 찾을 수 없습니다.
  • 위와 같은 에러가 발생하여 주피터를 실행할 수가 없었음.
  • Trial and error
    • Install OpenSSL and set env path: 연구실 컴퓨터는 주피터가 정상적으로 작동하는데, 연구실 컴퓨터에는 OpenSSL이 환경변수 path로 설정되어 있음을 발견하여 노트북에도 해당 폴더를 설치하고 환경변수를 설정 => Failed
    • Set anaconda path at env path: github issue를 참고하여 환경변수 path에 Anaconda/Library/bin을 추가 => Failed
    • Conda config --set ssl_verify False: 블로그를 참고함 => Failed
    • conda install openssl : openssl이 아나콘다에 설치가 안 되었나 해서 설치해봄 => Failed
  • Solution
    • "아나콘다경로/Library/bin/" 경로 열기
    • 다음 네 가지 파일들을 복사
      • libcrypto-1_1-x64.dll
      • libcrypto-1_1-x64.pdb
      • libssl-1_1-x64.dll
      • libssl-1_1-x64.pdb
    • "아나콘다경로/DLLs/" 경로에 붙여넣기

Anaconda 가상환경

conda install tensorflow

(base) conda create -n tf2 python=3.7
(base) activate tf2
(tf2) conda install tensorflow
  • tensorflow 2버전 이상에서는 conda를 사용한 tensorflow 설치가 권장된다.

tf2 가상환경에서 jupyter notebook 사용하기

(tf2) conda install jupyter notebook
  • jupyter notebook은 base(root)를 바탕으로 실행된다(jupyter가 base에 설치되어 있기 때문). 따라서 가상환경에도 jupyter를 설치해줘야 한다.
  • Problem: tf2 가상환경에서는 ssl import에러가 다시 발생.
  • Reason: 위의 DLLs에 dll 파일 복사한 것은 base 환경이기 때문.
  • Solution: tf2 환경에도 마찬가지로 Libary/bin의 4가지 dll과 pdb 파일을 복사하여 DLLs에 붙여넣어야 함.

jupyter notebook 실행

(tf2) jupyter notebook
  • tensorflow 확인
    • tf2 환경에서 실행된 주피터에서 파일을 생성한다.
    • image

댓글