skip to Main Content

Trying to install python 3.8 from source in CentOS 7.9.

The default installed python is 2.7.5 and is located at /usr/bin.

sudo yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel
sudo cd /opt
sudo wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz
sudo tar xzf Python-3.8.12.tgz
cd Python-3.8.12
sudo ./configure --enable-optimizations
sudo make install

I thought make install would create python3 in /usr/bin, but it didn’t.

2

Answers


  1. By default, CPython install compiled python binary in /usr/local/bin/python. (source code: https://github.com/python/cpython/blob/main/configure#L571) You may specify the prefix mannually as configure --prefix=/usr.

    Login or Signup to reply.
  2. You need to set symlinks such as

    $ sudo ln -sfn /usr/local/bin/python3.8 /usr/bin/python3.8
    $ sudo ln -sfn /usr/local/bin/pip3.8 /usr/bin/pip3.8
    

    The above works great in CentOS7 after installing Python3.8 as noted above.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search