OS/Linux
[Linux] Install Python using Source
llHoYall
2022. 2. 2. 11:29
Prerequisites
We need to gcc, openssl, bzip, and libffi.
$ sudo yum install gcc openssl-devel bzip2-devel libffi-devel
Download Python
Download Python source from FTP storage via wget.
$ cd /opt
$ sudo wget https://www.python.org/ftp/python/3.x.x/Python-3.x.x.tgz
Extract the Archive Python File
$ sudo tar xzf Python-3.x.x.tgz
Install Python
$ cd Python-3.x.x
$ sudo ./configure --enable-optimizations
$ sudo make altinstall
make altinstall prevents replacing the default Python binary in /usr/bin/python.
Check Python Version
Installed Python is located in /usr/local/bin directory.
If you installed Python v3.9.x, you can check its version like this.
$ python3.9 -V
Clean Up
Remove the downloaded source file for cleaning up.
$ sudo rm -f /opt/Python-3.9.6.tgz
반응형