Ask Your Question

How do I install Python 2.6.x on a CentOS 7 machine using Puppet/yum/EPEL?

asked 2017-11-13 17:59:12 -0600

PQG gravatar image


I'm working on writing a puppet file that can be included that installs Python 2.6 on a CentOS7 remote VM. This file is being written so that Python apps that run on v2.6 can be cloned from Git onto the VM and then run immediately. The VM is running Puppet v3.8.7, yum v3.4.3, and EPEL 7.

Snippet of the relevant code that I have so far:

package { 'python26':
    ensure   => 'installed',
    provider => 'yum',
package {
    ensure => 'installed',

However, when that snippet gets run on the VM, it errors as follows:

Error: Execution of '/usr/bin/yum -d 0 -e 0 -y install python26' returned 1: Error: Nothing to do
Error: /Stage[main]/.../Python2_6/Package[python26]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y install python26' returned 1: Error: Nothing to do

I did a little bit of research and it appears that EPEL 7 doesn't have the python26 package referenced here (an old article, back when people were trying to upgrade from v2.4 to v2.6), and EPEL7's default python package installs v2.7 now. I spent about 2 hours searching through forums and documentation looking for ways to install v2.6 instead of the default v2.7 (even made it all the way to the 3rd result page of Google), and the best answer I've found so far is this article which would require me to essentially run a Bash script through Puppet's exec statements, which doesn't sound like a good solution right now.

I've also tried running this on the VM :

yum list all | grep python

and looking for a 2.6 version, but I didn't see any that looked like what I want.

Do any of you have experience with a similar situation that might provide an answer? Is there a yum/EPEL package that I've overlooked that would install Python 2.6?

Thank you in advance for any help or advice that you can offer! :-)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-14 04:44:04 -0600

stivesso gravatar image

updated 2017-11-17 01:36:40 -0600


I think that one of the approach you might use to avoid going through many exec will be to build Custom Python 2.6 rpm package from the source and write a manifest that will install that RPM.
This thread ( was about building/compiling such packages, and as recommended by @gh, fpm seems to be a great tool for custom compile software and building packages. See below an example of how we can build/install Python 2.6 on CentOS7 using fpm (you can/must get to fpm documentation if you decide to use that method..).

Building the rpm package:

# Install fpm
yum install ruby-devel gcc make rpm-build rubygems
gem install --no-ri --no-rdoc fpm

# Install prerequisite to compile Python
yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

# Get Python 2.6
mkdir ~/build
cd ~/build
tar zxvf Python-2.6.9.tgz

# Compile Python 2.6
cd Python-2.6.9
./configure --prefix=/opt/python26 --enable-shared

# Instead of installing these files that we've configured on our system
# we will install them into an empty, dummy directory that we can build a real package out of
mkdir -p /tmp/project
make DESTDIR=/tmp/project install

# Create the rpm with fpm 
fpm -s dir -t rpm -C /tmp/project --name python26 --version 2.6.9 --iteration 1 --description "Python 2.6 for RHEL7" 

# Check your package and install...
rpm -qpi python26-2.6.9-1.x86_64.rpm 
yum localinstall python26-2.6.9-1.x86_64.rpm

Install the rpm
With that rpm file, it is generally advisable to use a local yum repo! If you don't use local yum repo, then you may have to copy the file first and install the package as seen below.

 file { "/tmp/python26-2.6.9-1.x86_64.rpm":
   source => 'puppet:///modules/profile/python26-2.6.9-1.x86_64.rpm',

 package { 'python26':
   ensure    => installed,
   provider  => 'rpm',
   source    => '/tmp/python26-2.6.9-1.x86_64.rpm',
   require   => File["/tmp/python26-2.6.9-1.x86_64.rpm"],

# Used just for running ldconfig as I used an alternate directory during the compile (/opt/python26/lib)
file { "/etc/":
  content => '/opt/python2.6/lib',
  notify  => Exec['ldconfig-rebuild']

exec { 'ldconfig-rebuild':
  refreshonly => true,
  path        => '/sbin',
  command     => '/sbin/ldconfig',

I hope I was able to help...

Below are some References/Links you can use if you want to get more understanding on this topic:,,

edit flag offensive delete link more


This looks excellent! I'll give it a try. Thank you very much for your detailed and well-referenced answer.

PQG gravatar imagePQG ( 2017-11-14 14:54:06 -0600 )edit

stivesso, This answer works! Thank you very much! When going through your instructions, I noticed that ./configure --prefix=/opt/python26 --libdir= --enable-shared didnt have a value for --libdir, so I just set it to be the same as prefix. That worked ok, but I'm wondering what you had intended

PQG gravatar imagePQG ( 2017-11-16 18:52:07 -0600 )edit

to put there. On one of my later builds, I had set the --prefix to /usr so that it would install alongside the Python 2.7 on the CentOS machine, but Puppet gave me an error "file /usr/bin/python from install of python26-2.6.9-2.x86_64 conflicts with file from package python-2.7.5-58.el7.x86_64"

PQG gravatar imagePQG ( 2017-11-16 18:55:29 -0600 )edit

Do you have any suggestions on how to make the 2.6.9 RPM install alongside the existing python?

PQG gravatar imagePQG ( 2017-11-16 18:56:25 -0600 )edit

Hi PQG, I'm glad to hear that it worked! :-) the --libdiir was a little mistake, I edited the answer to remove it. The default python binary directory for the official rpm is /usr/bin, that's why I used the prefix to set an alternate directory...

stivesso gravatar imagestivesso ( 2017-11-17 01:41:22 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-11-13 17:59:12 -0600

Seen: 2,415 times

Last updated: Nov 17 '17