Programing

pip3로 패키지를 설치할 때 "Python의 SSL 모듈을 사용할 수 없습니다"

lottogame 2020. 11. 26. 07:46
반응형

pip3로 패키지를 설치할 때 "Python의 SSL 모듈을 사용할 수 없습니다"


로컬 컴퓨터에 Python 3.4 및 Python 3.6을 성공적으로 설치했지만 pip3.

실행할 때 pip3 install <package>다음과 같은 SSL 관련 오류가 발생합니다.

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting <package>
  Could not fetch URL https://pypi.python.org/simple/<package>/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement <package> (from versions: )
No matching distribution found for <package>

패키지를 설치할 수 있도록 Python3.x 설치를 어떻게 수정 pip install <package>합니까?


Ubuntu에 Python 3.6 및 pip3을 설치하는 단계별 가이드

  1. Python 및 SSL에 필요한 패키지를 설치합니다. $ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

  2. https://www.python.org/ftp/python/ 에서 "Python-3.6.8.tar.xz"를 다운로드 하여 홈 디렉토리에 압축을 풉니 다 .

  3. 해당 디렉토리에서 터미널을 열고 다음을 실행하십시오. $ ./configure

  4. 빌드 및 설치 : $ sudo make && sudo make install

  5. 다음을 사용하여 패키지 설치 : $ pip3 install package_name


Red Hat / CentOS를 사용하는 경우 :

# To allow for building python ssl libs
yum install openssl-devel
# Download the source of *any* python version
cd /usr/src
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar xf Python-3.6.2.tar.xz 
cd Python-3.6.2

# Configure the build w/ your installed libraries
./configure

# Install into /usr/local/bin/python3.6, don't overwrite global python bin
make altinstall

Windows에서 아나콘다를 사용하는 경우 이것은 나를 위해 일했습니다.

작동하지 않는 다른 솔루션을 많이 시도했습니다 (환경 경로 변수 변경 ...)

이 문제는 Windows \ System32 폴더의 DLL (예 : libcrypto-1_1-x64.dll 또는 libssl-1_1-x64.dll 또는 기타)에 의해 다른 소프트웨어에 의해 발생할 수 있습니다.

수정 사항은 https://slproweb.com/products/Win32OpenSSL.html 에서 openSSL을 설치하는 것이 었으며 이는 dll을 최신 버전으로 대체했습니다.


mastaBlasta의 답변에 동의하십시오. 나를 위해 일했습니다. 주제 설명과 동일한 문제가 발생했습니다.

환경 : MacOS Sierra. 그리고 저는 Homebrew를 사용합니다.

내 솔루션 :

  1. 의해 openssl을 다시 설치하십시오 brew uninstall openssl, brew install openssl.
  2. Homebrew가 제공하는 힌트에 따라 다음을 수행하십시오.

    echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

    export LDFLAGS="-L/usr/local/opt/openssl/lib"

    export CPPFLAGS="-I/usr/local/opt/openssl/include"


라이브러리 누락으로 인한 문제 일 수 있습니다.

Python 3.6을 설치하기 전에 Python에 필요한 모든 라이브러리를 설치했는지 확인하십시오.

$ sudo apt-get install build-essential checkinstall 
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Ubuntu 및 LinuxMint에 Python 3.6.0을 설치하는 방법에 대한 추가 정보


Ubuntu에서는 다음이 도움이 될 수 있습니다.

cd Python-3.6.2
./configure --with-ssl
make
sudo make install

Windows 10에서 동일한 문제가 발생했습니다. 내 특정 문제는 Anaconda 설치로 인한 것입니다. Anaconda를 설치했고 경로 아래 Path/to/Anaconda3/python.exe. 따라서 Anaconda에는 파이썬이 포함되어 있기 때문에 파이썬을 전혀 설치하지 않았습니다. pip를 사용하여 패키지를 설치할 때 동일한 오류 보고서 인 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available..

해결책은 다음과 같습니다.

1) 공식 웹 사이트 에서 파이썬을 다시 다운로드 할 수 있습니다 .

2) "Python 3.7 (64-bit).lnk"위치한 디렉토리로 이동하십시오.

3) import ssl그리고exit()

4) "Python 3.7 (64-bit).lnk" -m pip install tensorflow예를 들어 cmd를 입력하십시오 .

여기에서 모든 설정이 완료되었습니다.


OSX를 사용 중이고 소스에서 Python을 컴파일 한 경우 :

brew를 사용하여 openssl 설치 brew install openssl

brew가 제공하는 지침을 따라 CPPFLAGSLDFLAGS. 제 경우에는 openssl@1.1brew 공식을 사용하고 있으며 SSL 라이브러리에 올바르게 연결하려면 Python 빌드 프로세스에 대해 다음 세 가지 설정이 필요합니다.

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

라이브러리가 해당 위치에 설치되어 있다고 가정합니다.


Windows 에서 Anaconda를 사용하는 경우 사용자 willliu1995가 여기에서 제안한대로 cmd.exe 대신 Anaconda 프롬프트에서 "pip install ..."명령을 실행할 수 있습니다 . 이것은 추가 구성 요소를 설치할 필요가없는 가장 빠른 솔루션이었습니다.


이 문제를 해결하기 위해 많은 방법을 시도했지만 해결되지 않았습니다. 현재 Windows 10을 사용 중입니다.

효과가 있었던 유일한 것은 :

  • Anaconda 제거
  • Python 제거 (버전 3.7.3 사용 중)
  • Install Python again (remember to check the option to automatically add to PATH)

Then I've downloaded all the libs I needed using PIP... and worked!

Don't know why, or if the problem was somehow related to Anaconda.


I was having the same issue and was able to resolve with the following steps:

sudo yum install -y libffi-devel
sudo yum install openssl-devel
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
sudo tar xf Python-3.7.1.tar.xz
cd Python-3.7.1
sudo ./configure --enable-optimizations
# Install into /usr/local/bin/python3.7, don't overwrite global python bin
sudo make altinstall

depending on perms, you may not need sudo.

Results:
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

should now be able to run

python3.7 -V 

and

pip3.7 -V

When installing packages:

pip3.7 install pandas

or depending on perms, you can also add the --user flag like so:

pip3.7 install pandas --user

I was having the same problem for the last two days and only have fixed it right now.

I had tried to use --trust-host option with the DigiCert_High_Assurance_EV_Root_CA.pem did not work, I couldn't install the ssl module (It tells it cannot be installed for python versions greater than 2.6), setting the $PIP_CERT variable didn't fix it either and I had libssl1.0.2 and libssl1.0.0 installed. Also worth mentioning I didn't had a ~/.pip/pip.conf file, and creating it didn't solve the bug either.

What finally solved it, was installing python3.6 with make again. Download the Python-3.6.0.tgz from the website, run configure then make, make test and make install. Hope it works for you.


I had the same issue trying to install python3.7 on an ubuntu14.04 machine. The issue was that I had some custom folders in my PKG_CONFIG_PATH and in my LD_LIBRARY_PATH, which prevented the python build process to find the system openssl libraries.

so try to clear them and see what happens:

export PKG_CONFIG_PATH=""
export LD_LIBRARY_PATH=""

The ssl module is a TLS/SSL wrapper for accessing Operation Sytem (OS) socket (Lib/ssl.py). So when ssl module is not available, chances are that you either don't have OS OpenSSL libraries installed, or those libraries were not found when you install Python. Let assume it is a later case (aka: you already have OpenSSL installed, but they are not correctly linked when installing Python).

I will also assume you are installing from source. If you are installing from binary (ie: Window .exe file), or package (Mac .dmg, or Ubuntu apt), there is not much you can do with the installing process.

During the step of configuring your python installation, you need to specify where the OS OpenSSL will be used for linking:

# python 3.8 beta
./configure --with-openssl="your_OpenSSL root"

So where will you find your installed OpenSSL directory?

# ubuntu 
locate ssl.h | grep '/openssl/ssl.h'

/home/user/.linuxbrew/Cellar/openssl/1.0.2r/include/openssl/ssl.h
/home/user/envs/py37/include/openssl/ssl.h
/home/user/miniconda3/envs/py38b3/include/openssl/ssl.h
/home/user/miniconda3/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.0.2s-h7b6447c_0/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.1.1b-h7b6447c_1/include/openssl/ssl.h
/home/user/miniconda3/pkgs/openssl-1.1.1c-h7b6447c_1/include/openssl/ssl.h
/usr/include/openssl/ssl.h

Your system may be different than mine, but as you see here I have many different installed openssl libraries. As the time of this writing, python 3.8 expects openssl 1.0.2 or 1.1:

Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().

So you would need to verify which of those installed libraries that you can use for linking, for example

/usr/bin/openssl version

OpenSSL 1.0.2g  1 Mar 2016
./configure --with-openssl="/usr"
make && make install

You may need to try a few, or install a new, to find the library that would work for your Python and your OS.


The python documentation is actually very clear, and following the instructions did the job whereas other answers I found here were not fixing this issue.

  1. first, install python 3.x.x from source using, for example with version 3.6.2 https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

  2. make sure you have openssl installed by running brew install openssl

  3. unzip it and move to the python directory: tar xvzf Python-3.6.2.tar.xz && cd Python-3.6.2

  4. then if the python version is < 3.7, run

CPPFLAGS="-I$(brew --prefix openssl)/include" \ LDFLAGS="-L$(brew --prefix openssl)/lib" \ ./configure --with-pydebug 5. finallly, run make -s -j2 (-s is the silent flag, -j2 tells your machine to use 2 jobs)

참고URL : https://stackoverflow.com/questions/41328451/ssl-module-in-python-is-not-available-when-installing-package-with-pip3

반응형