본문 바로가기
이것저것

ImportError: Can not find the shared library: libhdfs3.so

by T&T 2022. 5. 13.
반응형

JupyterLab에서 HDFS와의 연동 테스트를 하던 중 아래와 같이 테스트 코드를 작성하여 테스트를 했는데

from hdfs3 import HDFileSystem

hdfs = HDFileSystem(host='***.***.***.***', port=8020)
hdfs.ls('/tmp')
hdfs.get('/tmp/test.csv', 'test.csv')

이렇게 에러가 발생하였습니다.

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_7732/2588692411.py in <module>
      1 from hdfs3 import HDFileSystem
      2 
----> 3 hdfs = HDFileSystem(host='***.***.***.***', port=8020)
      4 hdfs.ls('/tmp')
      5 hdfs.get('/tmp/test.csv', 'test.csv')

/opt/conda/lib/python3.7/site-packages/hdfs3/core.py in __init__(self, host, port, connect, autoconf, pars, **kwargs)
     86 
     87         if connect:
---> 88             self.connect()
     89 
     90     def __getstate__(self):

/opt/conda/lib/python3.7/site-packages/hdfs3/core.py in connect(self)
    104         This happens automatically at startup
    105         """
--> 106         get_lib()
    107         conf = self.conf.copy()
    108         if self._handle:

/opt/conda/lib/python3.7/site-packages/hdfs3/core.py in get_lib()
    668     global _lib
    669     if _lib is None:
--> 670         from .lib import _lib as l
    671         _lib = l
    672 

/opt/conda/lib/python3.7/site-packages/hdfs3/lib.py in <module>
     22             raise
     23 if _lib is None:
---> 24     raise ImportError("Can not find the shared library: libhdfs3.so\n"
     25                       "See installation instructions at "
     26                       "http://hdfs3.readthedocs.io/en/latest/install.html")

ImportError: Can not find the shared library: libhdfs3.so
See installation instructions at http://hdfs3.readthedocs.io/en/latest/install.html

친절하게 설명되어 있는 installation instruction을 보러 http://hdfs3.readthedocs.io/en/latest/install.html 으로 이동을 하였습니다.

 

위와 같은 내용을 보고 root로 접속하여 아래와 같은 명령어로 업데이트 및 재설치를 시도 하였습니다.

1. workspace -> File -> New launcher 접속
2. Other탭의 Terminal 실행.
3. 다음 명령어 복사 붙여넣기 후 실행하여 conda update 및 패키지 install 최신화

sudo -i
conda update -y conda && \
conda install -c conda-forge protobuf && \
pip install py4j && \
pip install --upgrade pip && \
pip install hdfs && \
conda install -y hdfs3 libhdfs3 -c conda-forge

잘 될줄 알았지만 안되더군요.

 

문제는 libhdfs3.so 파일에 libcrypto.so.3 dependency 못찾는 현상이었습니다.

libhdfs3 → openssl dependency가 안맞아서 발생한 사항으로 확인되었습니다.

우선 jupyter에서 아래 command 실행해서 정상동작 확인하였습니다.
!conda install libhdfs3=2.3=h163dcf3_1018 -y

 

각자 상황이 다 다르겠지만 참고용으로 작성하여 올립니다.

반응형

댓글