Reputation: 107
I just started to use Amazon Web Service and made an EC2 instance on Amazon Linux 2. Python 3.7 is installed on it but I want to use Python 3.10. So I decided to uninstall existing Python 3.7 and then install Python 3.10. At this moment, an warning message 'WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.' was appeared. As a result I could not update pip module and install libraries.
I already knew this article: PEP 644 – Require OpenSSL 1.1.1 or newer. So installation of OpenSSL v1.1.1 is required before installation of Python.
sudo yum update
sudo yum remove python3.7
sudo rm cert-verification.cfg
sudo rmdir python
openssl version
> OpenSSL 1.0.2k-fps
sudo yum remove openssl
sudo yum remove openssl-devel
wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz
tar -xzv openssl-1.1.1t.tar.gz
sudo yum install perl-core
.config --prefix=/usr/local/openssl-1.1.1t shared zlib
make depend
make
make test
sudo make install
sudo echo /usr/local/openssl-1.1.1t/lib > /etc/ld.so.conf.d/openssl-1.1.1t.conf
> "Permission denied" even though sudo is set.
su
> Password ******
echo /usr/local/openssl-1.1.1t/lib > /etc/ld.so.conf.d/openssl-1.1.1t.conf
exit
sudo ldconfig
nano /home/ec2-user/.bash_profile
> Path is added at the end of PATH.
> # User specific environment and start up programs
> PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/openssl-1.1.1t/bin
source ./.bash_profile
openssl version
> OpenSSL 1.1.1t 7 Feb 2023
Along this order, I confirmed that openssl is successfully updated.
wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tar.xz
tar -vxf Python-3.10.10.tar.xz
sudo yum install gcc
./configure --enable-optimizations
make
sudo make install
Installation seems to be successful but a following messages is shown.
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behavior with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Following error message was shown when I tried to show the list installed.
pip3 list
Package Version
----------- ---------
pip 22.3.1
setuptools 65.5.0
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. 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.
I checked the version of openssl like following:
openssl verion (also shown in 3.4.)
> OpenSSL 1.1.1t 7 Feb 2023
It shows the latest version of openssl is installed. When I put a command like following:
yum info openssl
> Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
> Available packages
> Name: openssl
> Arch: x86_64
> Version: 1.0.2k
> Release:24.amzn2.0.6
I think this information shows that there is an 'Available packages', which means OpenSSL (=v1.0.2k) is not installed. So I thought only OpenSSL version 1.1.1t exists on the EC2 instance.
I also checked if ssl module can be imported correctly in Python console.
python3
Python 3.10.10 (main, Mar 1 2023, 23:43:07) [GCC 7.3.1 20180712 (Red Hat 7.3.1-15)] on Linux
Type "help","copyright","credits" or "license" for more information.
>> import ssl
>>
As shown above, ssl module is importable. There is no problem.
Python 3.10.10 was successfully installed and ssl module is importable. However pip3 command is not executable because ssl module is not available in Python. What is the reason for this ? Please tell me what I should do to fix this issue.
Upvotes: 5
Views: 9896
Reputation: 107
I resolved this issue by myself. The problem was Python installation before installing OpenSSL. It is because OpenSSL is included while 'make' process, so OpenSSL should be installed before installing Python.
Upvotes: 4