以下のようなメッセージに遭遇した場合の対処
pip3 install --upgrade pip
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Requirement already satisfied: pip in /usr/local/lib/python3.10/site-packages (22.0.4)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
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
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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
実施したこと(opensslの入れ替え?)
#yum groupinstall "Development Tools" -y
#yum install openssl-devel libffi-devel bzip2-devel -y
以下3行は「あまり見ない導入操作」。これが実は効く。
#yum install -y epel
#yum install -y openssl11-devel
#sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure
Python3.10.5をダウンロードします。
#wget https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz
ダウンロードしたファイルを解凍します
#tar xvf Python-3.10.5.tgz
#cd Python-3.10.5
python3.10.5をインストールします
#./configure --enable-optimizations
#sudo make altinstall
PATHを通す
#ln -sf /usr/local/bin/python3.10 /usr/bin/python3
#ln -sf /usr/local/bin/pip3.10 /usr/bin/pip3
pythonバージョンを確認
#python3 --version
Python 3.10.5
環境設定
#echo 'LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/python3.9/lib"' >> ~/.bashrc
#echo 'PATH="$PATH:/usr/local/python3.9/bin"' >> ~/.bashrc
#source ~/.bashrc
pipのバージョンを確認します
#pip3 --version
pip 21.2.4 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)
おそらく最近、よく失敗する操作のpipのUpgrade。
冒頭の「あまり見ない導入操作」を行うとできりようになりました。
#pip3 install --upgrade pip
Requirement already satisfied: pip in /usr/local/lib/python3.10/site-packages (22.0.4)
Collecting pip
Downloading pip-22.1.2-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 16.1 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
Successfully uninstalled pip-22.0.4
Successfully installed pip-22.1.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
無事Python3の導入と、pip3の導入およびUpgradeは完了!