Python 패키지를 설치할 수 없음 [SSL : TLSV1_ALERT_PROTOCOL_VERSION]
pip
SSL 오류가 발생 하여를 사용하여 Python 라이브러리를 설치하려고합니다 .
~/projects/base pre-master± pip install xdict
Collecting xdict
Could not fetch URL https://pypi.python.org/simple/xdict/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Could not find a version that satisfies the requirement xdict (from versions: )
No matching distribution found for xdict
핍 버전 : pip 9.0.1
이 오류를 어떻게 해결합니까?
다음과 같이 핍을 업그레이드하십시오.
curl https://bootstrap.pypa.io/get-pip.py | python
참고 : sudo python
가상 환경이 아닌 경우 위 를 사용해야 할 수도 있습니다.
( 즉, 을 pip
사용하여 업그레이드해도 제대로 업그레이드되지는 않습니다. 이는 닭과 계란 문제 일뿐입니다. TLS> = 1.2를 사용하지 않으면 작동하지 않습니다.)pip
pip install --upgrade pip
pip
이 자세한 답변 에서 언급했듯이 최근 pip에 대한 TLS 지원 중단으로 인한 것입니다. Python.org 사이트는 TLS 버전 1.0 및 1.1에 대한 지원 을 중단했습니다 .
Python 상태 페이지에서 :
완료 -롤링 브라운 아웃이 완료되었으며 TLSv1.0 및 TLSv1.1이 비활성화되었습니다. 4 월 11 일 15:37 UTC
PyCharm (virtualenv) 사용자의 경우 :
쉘로 가상 환경을 실행하십시오. ( "./venv/bin/activate"를 자신의 경로로 바꾸십시오)
source ./venv/bin/activate
업그레이드 실행
curl https://bootstrap.pypa.io/get-pip.py | python
PyCharm 인스턴스를 다시 시작하고 Preference 에서 Python 인터프리터를 확인하십시오 .
그러나 curl
명령 자체가 오류와 함께 실패하거나 업그레이드 후에도 "tlsv1 경고 프로토콜 버전"이 지속되면 pip
운영 체제의 기본 OpenSSL 라이브러리 버전 < 1.0.1
또는 Python 버전 < 2.7.9
(또는 3.4
Python 3의 < )이 최신 TLS 1.2 프로토콜을 지원하지 않음을 의미합니다 것을 pip
요구하기 때문에 PyPI에 연결하는 약 년 전 . 파이썬 인터프리터에서 쉽게 확인할 수 있습니다.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8o 01 Jun 2010'
>>> ssl.PROTOCOL_TLSv1_2
AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'
AttributeError
(대신 예상 '5')는 파이썬 다음 stdlib 의미 ssl
구하려면 openssl lib 디렉토리에 컴파일 된 모듈은, (에서 OpenSSL 라이브러리가 이상 업데이트 할 수 있습니다 경우에도)을 TLSv1.2 프로토콜에 대한 지원이 부족하다.
다행히도 추가 Python 패키지를 수동으로 설치하여 Python (및 전체 시스템) 을 업그레이드하지 않고도 해결할 수 있습니다 . 자세한 단계별 가이드는 여기에서 확인할 수 있습니다 .
참고
curl
와pip
및wget
모든 것은 SSL 연결을 (사용 설정에 대해 동일한 OpenSSL을 lib 디렉토리에 따라$ openssl version
명령). libcurl에서 지원은 컬 버전 1.2 이후 TLS 7.34 ,하지만 오래된 컬 버전은 해야 연결할 수 있다면 당신은 OpenSSL 버전 1.0.2 (이상)했다.
PS
의 경우 파이썬 3 , 사용하시기 바랍니다python3
및pip3
사방 (당신이에하지 않는 한 venv / VIRTUALENV)에 포함curl
에서 명령 위 :
$ curl https://bootstrap.pypa.io/get-pip.py | python3 --user
OS X에서 @Anupam의 답변에 따라 실행 권한에 관계없이 다음과 같은 오류가 발생했습니다.
EnvironmentError로 인해 패키지를 설치할 수 없습니다 : [Errno 13] 권한 거부 : ...
결국 작동하는 것은 내 브라우저 ( https://pypi.org/simple/pip/ )에서 PyPI에서 최신 pip 패키지 (9.0.3)를 직접 다운로드 하고 내용을 추출한 다음 로컬로 패키지를 pip 설치하는 것이 었습니다 .
pip install ./pip-9.0.3/
이것은 내 [SSL: TLSV1_ALERT_PROTOCOL_VERSION]
오류를 수정했습니다.
로컬 버전을 업그레이드하기 위해 약간의 변형을 사용했습니다.
curl https://bootstrap.pypa.io/get-pip.py | python - --user
에 설명 된대로 홈 디렉토리 아래 핍과 패키지를 유지하는 경우이 문제가 발생 이 요점 .
다음 솔루션이 저에게 효과적이었습니다.
brew install python2
또한 pip
버전 1.10.1로 업그레이드
@Anupam's solution worked for me. However, I had to use sudo
and specify the exact location of my virtual Python environment:
curl https://bootstrap.pypa.io/get-pip.py | sudo /Users/{your user name}/{path to python}/bin/python
Check your TLS version:
python2 -c "import urllib2,json; print(json.loads(urllib2.urlopen('https://www.howsmyssl.com/a/check').read())['tls_version'])"
If your TLS version is less than 1.2 you have to upgrade it since the PyPI repository is on a brownout period of deprecating early TLS.
Source - Time To Upgrade Your Python: TLS v1.2 Will Soon Be Mandatory
You can upgrade the TLS version using the following command:
sudo apt-get update && sudo apt-get install openssl libssl-dev
This should fix your problem. Good luck!
EDIT: You can download packages using your own private python package repository regardless of TLS version. Private Python Package Repository
This worked for me. Add sudo before python
curl https://bootstrap.pypa.io/get-pip.py |sudo python
For Python2 WIN10 Users:
1.Uninstall python thoroughly ,include all folders.
2.Fetch and install the lastest python-2.7.msi (ver 2.7.15)
3.After step 2,you may find pip had been installed too.
4.Now ,if your system'env haven't been changed,you can use pip to install packages now.The "tlsv1 alert protocol version" will not appear.
I tried all existing fixes and not working for me
I re-install python 2.7 (will also install pip) by downloading .pkg at https://www.python.org/downloads/mac-osx/
works for me after installation downloaded pkg
I ran into this problem as well. The underlying problem is that the ssl library in Python 2.7 versions < 2.7.9 is no longer compatible with the pip mechanism.
If you are running on Windows, and you (like us) can't easily upgrade from an incompatible version of 2.7, FWIW, I found that if you copy the following files from another install of the latest version of Python (e.g. Python 2.7.15) on another machine to your installation:
Lib\ssl.py
libs\_ssl.lib
DLLs\_ssl.dll
it will effectively "upgrade" your SSL layer to one which is supported; we were then be able to use pip again, even to upgrade pip.
This worked for me, I installed latest version of pip and then installed the library (ciscoconfparse).
Upgrading pip:
curl https://bootstrap.pypa.io/get-pip.py | sudo /Users/{your user name}/{path to python}/bin/python
myenv:
python 2.7.14
pip 9.0.1
mac osx 10.9.4
mysolution:
download
get-pip.py
manually from https://packaging.python.org/tutorials/installing-packages/run
python get-pip.py
refs:
https://github.com/pypa/warehouse/issues/3293#issuecomment-378468534
https://packaging.python.org/tutorials/installing-packages/
Securely Download get-pip.py [1]
Run python get-pip.py. [2] This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already.
Ensure pip, setuptools, and wheel are up to date
While pip alone is sufficient to install from pre-built binary archives, up to date copies of the setuptools and wheel projects are useful to ensure you can also install from source archives:
python -m pip install --upgrade pip setuptools wheel
I also hit this problem on my windows10 and tried all the answers but didn't solve my problem.
C:\python367\Scripts>pip install Flask
Collecting Flask Could not find a version that satisfies the requirement Flask (from versions: ) No matching distribution found for Flask
After that, I find the pip configuration file had been modified. So, I set the pip.ini
as the original default configuration, re-run the pip command and it works for me!
In summary of the solution of mine:
Check the pip.ini (usually under the path
C:\ProgramData\pip
) had been modified;If yes in step1, try to reset it to a default configuration.
Or simply the required library just isn't in the repo. I'm Python newbie and all advices about upgrading pip finally shown as misleading. I had just to look into https://pypi.org/ , finding the library (airflow in my case) stopped at some old version, after which it was renamed. Yes, also that silly solution is also possible :-).
For all the python3
and pip3
users out there:
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
and then assume you want to install pandas
pip3 install pandas --user
'Programming' 카테고리의 다른 글
Google Play 개발자 콘솔에서 앱을 게시 취소하는 방법 (0) | 2020.06.01 |
---|---|
ImportError : PIL이라는 모듈이 없습니다 (0) | 2020.06.01 |
CSS / HTML 만 사용하여 깨진 아이콘을 숨기는 방법은 무엇입니까? (0) | 2020.06.01 |
Python 3 : UnboundLocalError : 할당 전에 참조 된 로컬 변수 (0) | 2020.06.01 |
쉘 명령에서 데이터베이스를 작성하는 방법은 무엇입니까? (0) | 2020.06.01 |