경고: pip가 TLS/SSL을 요구하도록 구성되었지만 Python의 SSL 모듈을 사용할 수 없습니다.

경고: pip가 TLS/SSL을 요구하도록 구성되었지만 Python의 SSL 모듈을 사용할 수 없습니다.

Kali Linux 2020.1을 사용하고 있으며 Python3.7을 설치한 후 pip3 명령을 사용하여 모듈을 설치하려고 하면 이 오류 메시지가 계속 나타납니다.

  WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    ERROR: Could not find a version that satisfies the requirement flask (from versions: none)
    ERROR: No matching distribution found for flask

    Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

답변1

이를 위해서는 이를 컴파일하고 모든 종속성을 설치해야 합니다.

  • 필요하시면 다운받으시면 됩니다 https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.x
  • 파일 압축 풀기
    tar zxvf Python-3.7.0.tar.gz --directory /tmp
    cd /tmp
    
  • Setup.distSSL을 활성화하려면 파일을 편집하세요.
    cd Python-3.7.0/Modules/
    vi Setup.dist
    
  • 다음 줄의 주석 처리를 해제하고 openssl홈페이지를 업데이트하세요.
    SSL=/usr/local/ssl  <--- substitute with your openssl home directory
    _ssl _ssl.c \
            -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
            -L$(SSL)/lib -lssl -lcrypto
    
  • 배포용 Python 저장 및 컴파일
    cd ../
    ./configure --enable-optimizations CFLAGS="-O3" --prefix=/opt/primeur/python3.7
    make
    make install
    
  • 시도 해봐

    cd /opt/primeur/python3.7/bin
    [root@myserver bin]# python3
    
    Python 3.7.0 (default, May 5 2020, 22:31:07)
    
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
    
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    
  • pip명령으로 업데이트

    [root@myserver bin]#./pip3 install --upgrade pip
    
  • pip3 install다음과 같은 것을 사용하여 종속성을 설치하십시오.

    [root@myserver bin]#./pip3 install termcolor
    
    Collecting termcolor
    Using cached https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
    Installing collected packages: termcolor
    Running setup.py install for termcolor ... done
    Successfully installed termcolor-1.1.0
    

답변2

내 생각엔 당신이 필요한 것을 실수로 설치했을 수도 있습니다. 오류는 다음으로 인해 발생하는 것 같습니다.파이썬 요청 라이브러리.

올바르게 설치되었는지, 종속성이 충족되는지 확인하겠습니다. 알고 보니 이 패키지는 python-openssl필수 패키지가 아닌 권장 패키지일 뿐입니다. 이것을 설치하는 것이 도움이 되는지 확인하고 싶을 수도 있습니다.

Package: python3-requests
Depends: python3-certifi, python3-chardet (<< 3.1.0), python3-idna, python3-urllib3 (<< 1.26), python3:any, ca-certificates, python3-chardet (>= 3.0.2), python3-urllib3 (>= 1.21.1)
Suggests: python3-cryptography, python3-idna (>= 2.5), python3-openssl, python3-socks, python-requests-doc

답변3

이 솔루션은 나에게 완벽하게 작동합니다.

소스에서 설치된 Python 3.7 SSL 문제

고마워요 조쉬.

프로세스를 요약해 보겠습니다.


속도

최신 버전의 소스 코드를 다운로드하여 openSSL을 다시 설치하기로 결정했습니다.

sudo apt-get install -y wget
mkdir /tmp/openssl
cd /tmp/openssl
wget https://www.openssl.org/source/openssl-1.0.2q.tar.gz
tar xvf openssl-1.0.2q.tar.gz
cd /tmp/openssl/openssl-1.0.2q
./config
make
sudo make install

여기서 핵심(그리고 내가 이 기사를 쓴 이유)은 Python에 새로 설치된 openSSL이 어디에 있는지 알려주는 방법을 보여주기 위한 것입니다. 기본적으로 수동으로 설치된 openSSL은 /usr/local/sslssl 디렉터리의 수정 시간을 확인하여 확인할 수 있습니다 ls -la /usr/local/ssl.

기본적으로 Python은 여기를 보지 않습니다. 우리는 이 문제를 해결해야 합니다. 먼저 Python 설치 스크립트의 첫 번째 부분을 실행합니다(아래 표시).

# Install requirements
sudo apt-get install -y build-essential
sudo apt-get install -y checkinstall
sudo apt-get install -y libreadline-gplv2-dev
sudo apt-get install -y libncursesw5-dev
sudo apt-get install -y libssl-dev
sudo apt-get install -y libsqlite3-dev
sudo apt-get install -y tk-dev
sudo apt-get install -y libgdbm-dev
sudo apt-get install -y libc6-dev
sudo apt-get install -y libbz2-dev
sudo apt-get install -y zlib1g-dev
sudo apt-get install -y openssl
sudo apt-get install -y libffi-dev
sudo apt-get install -y python3-dev
sudo apt-get install -y python3-setuptools
sudo apt-get install -y wget
# Prepare to build
mkdir /tmp/Python37
cd /tmp/Python37
# Pull down Python 3.7, build, and install
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xvf Python-3.7.0.tar.xz

이제 중지하고 CD를 사용 /tmp/Python37/Python-3.7.0하여 파일을 엽니다.Modules/Setup.dist

주석이 달린 다음 줄이 표시되어야 합니다.

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
 _ssl _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib -lssl -lcrypto

여러분이 해야 할 일은 Python 컴파일 프로세스 중에 이 줄의 주석 처리를 제거하여 이를 확인하는 것입니다. 이제 Python 스크립트의 마지막 몇 줄을 실행하여 이를 수행할 수 있습니다.

cd /tmp/Python37/Python-3.7.0
./configure --enable-optimizations
sudo make altinstall

이 시점에서 이제 작동하는 Python 및 pip가 있습니다(내 경로의 python3.7 및 pip3.7에 매핑됨).

답변4

Ubuntu 18.04 기반 PYNQ 시스템의 소스에서 Python 3.11.4를 설치하려고 합니다. 모든 종속성이 설치되었으며 위와 동일한 문제가 발생했습니다.

OpenSSL 버전 문제로 확인되었습니다.

  • openssl적절한 소스 코드의 버전은 1.1.0g입니다.
  • 설치 후libssl,libssl-dev,openssl버전 1.1.1에서는 문제가 해결되었습니다.

관련 정보