달나라 노트

Python Basic : pip install --trusted-host (trusted host에 URL 추가하기, Could not fetch URL https://pypi.org/simple/tableauserverclient/:There was a problem confirming the ssl certificate:HTTPSConnectionPool(host='pypi.org', port=443):Max retries e.. 본문

Python/Python Basic

Python Basic : pip install --trusted-host (trusted host에 URL 추가하기, Could not fetch URL https://pypi.org/simple/tableauserverclient/:There was a problem confirming the ssl certificate:HTTPSConnectionPool(host='pypi.org', port=443):Max retries e..

CosmosProject 2022. 5. 24. 18:53
728x90
반응형

 

 

 

Python을 사용하다보면 여러 패키지들을 설치하는건 거의 필수적입니다.

 

패키지를 설치할 땐 pip install command를 이용하거나 아니면 Pycharm의 Interpreter 메뉴에서 설치를 하게 되는데, 이때 간혹 이상한 이유로 설치가 안되는 경우가 있습니다.

 

제가 경험했던 한 경우는 tableauserverclient를 설치하려는데 자꾸 아래와 같은 에러가 뜨더라구요.

 

Could not fetch URL https://pypi.org/simple/tableauserverclient/:
There was a problem confirming the ssl certificate:
HTTPSConnectionPool(host='pypi.org', port=443):
Max retries exceeded with url: /simple/tableauserverclient/
(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)'))) - skipping

 

에러를 대략적으로 해석해보면 다음과 같습니다.

--> pypi.org로부터 tableauserverclient 라이브러리를 다운받으려고하는데 ssl 인증에서 문제가 발생했다.

 

이런 에러가 뜨는 원인은 주로 인트라넷을 사용하는 회사 컴퓨터나 또는 어떤 특정한 환경에서 사용하는 컴퓨터의 경우 신뢰할 수 있는 URL을 등록해놓는 경우가 있는데, 이때 Python 패키지를 다운받기 위한 URL이 등록되어있지 않은 경우 발생합니다.

 

그냥 Python 패키지를 다운받기 위한 URL이 신뢰할 수 있는 URL 리스트에 없기 때문이예요.

 

이런 경우 라이브러리를 설치할 때 그냥 pip install 패키지이름 을 사용하면 안되고 trusted-host 옵션을 추가해줘야합니다.

 

 

 

tableauserverclient 패키지를 설치하는 경우를 예시로 들자면 아래처럼 입력하면 됩니다.

 

pip install tableauserverclient --trusted-host pypi.org

 

pip install tableauserverclient 커맨드 뒤에 --trusted-host를 이용해서 pypi.org URL을 신뢰할 수 있는 URL 리스트에 추가하는 것입니다.

 

위 커맨드를 terminal에서 한번 실행시켜주면 tableauserverclient도 제대로 설치가 될것이고, 그 후에 Pycharm의 Interpreter 메뉴에서도 tableauserverclient를 검색해서 설치하면 이전과는 다르게 잘 설치가 될 것입니다.

 

 

 

 

 

--trusted-host 옵션은 단순히 pypi.org URL에만 사용할 수 있는 것이 아닙니다.

 

패키지를 다운받을 때 사용하는 여러 URL등이 있는데 그 중 몇개만 예시로 들어드리면 다음과 같습니다.

 

pip install test_lib --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org

 

하나의 pip install command에는 여러 개의 --trusted-host 옵션을 추가할 수 있습니다.

위 예시는 python library를 다운받을 때 사용되는 대표적인 URL을 trusted-host 옵션에 추가한 예시입니다.

 

이런식으로 응용해서 사용하면 됩니다.

 

 

 

 

 

 

728x90
반응형
Comments