## 문제 urllib3 을 사용할 때, 다음과 같은 에러가 발생하면서 python 스크립트가 실행되지 않는다. ``` ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips 26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168 ``` 원인을 파악해보고자 구글링을 하니 다음과 같은 공식 가이드와 짤막한 해결방안이 있었다. 요약하면, urllib3 부터는 OpenSSL 1.1.1+ 버전만을 지원하므로, 서버에 설치되어 있는 openssl 버전을 업그레이드 하여야 한다. 제공된 가이드의 경우 RHEL7 의 경우 os 업그레이드를 하라는 배보다 배꼽이 다소 더 큰 가이드를 하고 있다. [https://urllib3.readthedocs.io/en/latest/v2-migration-guide.html#common-upgrading-issues](https://urllib3.readthedocs.io/en/latest/v2-migration-guide.html#common-upgrading-issues) ## 해결방안 python 을 업그레이드한 openssl 을 연동해서 직접 컴파일하여 설치해보자. (아래의 [stackoverflow 글](https://stackoverflow.com/questions/69371800/how-to-link-python3-to-use-openssl11-or-latest-version-of-openssl-1-1-1-on-c)을 참고하였습니다.) ### OpenSSL 설치 ``` # Install OpenSSL 1.1.1 cd /opt curl https://ftp.openssl.org/source/old/1.1.1/openssl-1.1.1o.tar.gz --output openssl.tar.gz tar xzf openssl.tar.gz rm openssl.tar.gz cd openssl-1.1.1o/ # --prefix 경로에 openssl 을 설치합니다. ./config --prefix=/opt/openssl && make && make install ``` #### 설치 경로를 포함한 OpenSSL 버전 확인 ``` openssl version -d ``` ### 특정 OpenSSL 을 연동하여 python 설치 ``` # Install Python 3.8.18 cd /opt wget https://www.python.org/ftp/python/3.8.18/Python-3.8.18.tgz tar xzf Python-3.8.18.tgz cd Python-3.8.18 # 아까 설치했던 openssl 경로를 입력합니다. ./configure --with-openssl=/opt/openssl # build and install make make altinstall ``` ## 확인 ``` python3.8 > import ssl > ssl.OPENSSL_VERSION 'OpenSSL 1.1.1o 14 Dec 2021' ``` ### 참조 - [https://stackoverflow.com/questions/69371800/how-to-link-python3-to-use-openssl11-or-latest-version-of-openssl-1-1-1-on-c](https://stackoverflow.com/questions/69371800/how-to-link-python3-to-use-openssl11-or-latest-version-of-openssl-1-1-1-on-c)
하나의 파일에 여러 줄로된 정보를 저장해두고, bash로 일괄 처리하고 싶을 때 아래 코드를 복사해서 활용하자. ``` list=$(cat list.txt) # multi-line 으로 list 에 할당된다. while IFS= read -r item; do # TODO: do something echo $item done
댓글
댓글 쓰기