Installing Python on CentOS 6 - a big pain

J

John Nagle

It turns out that installing Python 2.7.2 on CentOS 6.0 is a lot of
work. Here are the official CentOS install instructions:

http://www.centos.org/modules/newbb/viewtopic.php?topic_id=34515&forum=41

Not only do you have to build Python from source, you have to install
a lot of stuff before you can even build it. Then you have to install
various Python packages from multiple sources. Python doesn't work
with "yum"; you have to do it the hard way.

I know how to do all this, but it takes hours. I'm bringing up
a bare dedicated server remotely, which is a routine operation.

Python does not "just work". I should be able to command
"yum install python27". (And not clobber the Python 2.6 that
comes with CentOS.)

This sort of thing is why Python is losing market share.


John Nagle
 
B

Benjamin Kaplan

 It turns out that installing Python 2.7.2 on CentOS 6.0 is a lot of work.
 Here are the official CentOS install instructions:

http://www.centos.org/modules/newbb/viewtopic.php?topic_id=34515&forum=41

Not only do you have to build Python from source, you have to install
a lot of stuff before you can even build it.  Then you have to install
various Python packages from multiple sources.  Python doesn't work
with "yum"; you have to do it the hard way.

I know how to do all this, but it takes hours.  I'm bringing up
a bare dedicated server remotely, which is a routine operation.

  Python does not "just work".  I should be able to command
"yum install python27".  (And not clobber the Python 2.6 that
comes with CentOS.)

  This sort of thing is why Python is losing market share.


                                       John Nagle
--

What does this have to do with Python? It's CentOS (and Red Hat's)
decision not to provide a package for Python 2.7. It's not feasible
for the Python community to provide a repository for each of the 200+
Linux distributions. The instructions for building Python are exactly
the same as to build any other large project and there is absolutely
nothing that we can do about that- you can't compile a program without
a compiler and you can't link to other programs without the
development headers. You'll have the exact same problems if you want
to install gcc 4.6.2 unless some 3rd party has decided to build the
rpm for you.
 
J

J.O. Aho

John said:
It turns out that installing Python 2.7.2 on CentOS 6.0 is a lot of work. Here
are the official CentOS install instructions:

http://www.centos.org/modules/newbb/viewtopic.php?topic_id=34515&forum=41

Don't see any official about the post, it's just another forum member who
posts what he did to install a later version of Python than the default 2.6
that comes with RedHat EL (and those comes with CentOS).

Not only do you have to build Python from source, you have to install
a lot of stuff before you can even build it.

To build a car, you need a lot of parts, and you need to build the engine too.
If you are building something yourself, you need header files and gcc, no
matter if it's python or something else you want, you need those things and
lucky you that you don't have something like ms-windows, then you don't have a
package manager which will install most of the things you need, you would need
to hunt down everything yourself (I know ms-win has already compiled versions,
but we are talking about compiling yourself).

Then you have to install
various Python packages from multiple sources. Python doesn't work
with "yum"; you have to do it the hard way.

That's the life when you don't want to use what you are given for free, I'm
sure someone would put up a repo for you if you paid them to compile python
and all the modules for it.

I know how to do all this, but it takes hours. I'm bringing up
a bare dedicated server remotely, which is a routine operation.

If you build your own RPMs, you can do that on your desktop machine, no need
to do it on the underpowered VPS or really, you should have picked a
distribution which gives you python 2.7 by default instead, just visit
distrowatch.com and you can find at least one within two minutes.

Python does not "just work". I should be able to command
"yum install python27". (And not clobber the Python 2.6 that
comes with CentOS.)

This sort of thing is why Python is losing market share.

It's not Python developers fault that some distributions choose to stay with
older versions of Python instead of switching to 3.2 at once, or that ms-win
don't have python at all.
If you want CentOS to have a newer python by default, then contact RedHat, but
before they listen to you, you may need to get some RedHat licenses.
 
S

Steven D'Aprano

This sort of thing is why Python is losing market share.

Only on Planet Nagle.

Do you have any evidence that Python actually *is* losing market share,
or are you just trolling?
 
A

Albert W. Hopkins

Python does not "just work". I should be able to command
"yum install python27". (And not clobber the Python 2.6 that
comes with CentOS.)

This sort of thing is why Python is losing market share.
Or — and this is the more likely scenario — it could be that this has
nothing to do with the Python language per sé and you are just playing
the whiny snot-nosed kid.
 
A

alex23

   It turns out that installing Python 2.7.2 on CentOS 6.0 is a lot of
work.

There must have been some radical changes between Centos 5 & 6, then,
as building Python 2.7 from scratch took all of 10 minutes.
 Here are the official CentOS install instructions:

The person who posted that has the forum designation "Newbie". Those
aren't the official anything.
Not only do you have to build Python from source, you have to install
a lot of stuff before you can even build it.  Then you have to install
various Python packages from multiple sources.  Python doesn't work
with "yum"; you have to do it the hard way.

I know how to do all this, but it takes hours.

So you're of course building an rpm as you go to prevent the need for
you or anyone else having to do this again, right? You're not some
selfish asshole who expects "The Python Community" to do everything
for him, are you?
Python does not "just work".  I should be able to command
"yum install python27".  (And not clobber the Python 2.6 that
comes with CentOS.)

If only someone had just recently boasted about being able to do just
this and had built an rpm to prove it...
    This sort of thing is why Python is losing market share.

If Python is losing anything it's from the endless FUD spouted by
yourself and others.
 
S

Steven D'Aprano

There must have been some radical changes between Centos 5 & 6, then, as
building Python 2.7 from scratch took all of 10 minutes.


Reading between the lines, I guess that John has set up his Centos boxes
without development tools. I've known sys admins like that: in an effort
to "increase security" they take away dev tools so that anybody breaking
in can't install anything underhanded, at least in theory.

With all the tools installed, it's a matter of a few minutes effort to
build from scratch:

download the tar ball
extract the contents of the file
cd into the source directory
run ./configure
run make
optionally run make test
run sudo make altinstall

As a total n00b who'd never used make before, it took me 25 minutes
effort on my first attempt, including reading the entire README file
(twice!). Now I have the whole process down to about 30 seconds effort,
and six minutes elapsed time, on my laptop.

But obviously you can't build from source without a compiler. So under
those circumstances, it would be very difficult to build from source, as
you need to install make, gcc, and who knows what other tools, and fight
with the cryptic error messages generated until eventually it all Just
Works. I hate to imagine how much effort would be involved.

And I can't fathom why John imagines that this is Python's fault.
 
C

Chris Angelico

With all the tools installed, it's a matter of a few minutes effort to
build from scratch:

run ./configure
run make
run sudo make altinstall

As a total n00b who'd never used make before, it took me 25 minutes
effort on my first attempt, including reading the entire README file
(twice!). Now I have the whole process down to about 30 seconds effort,
and six minutes elapsed time, on my laptop.

The first time I built a Python 3, I didn't know about 'make
altinstall', and managed to make something of a mess of my system (the
default Python is 2.6.6 on Ubuntu, IIRC, and there are system scripts
that don't work on Py3). But now, it's pretty easy, as yesterday can
attest: I did a fresh install of Debian, starting at about 11AM, and
by mid-afternoon everything was built and deployed. Most of that time
was spent cloning about 8-10 source repositories (including one local
one of "work stuff") and building stuff from source, and not one of
the programs gave me any trouble. Python 3 was among them.

Now, granted, this was Debian and I can't speak for Centos. But it
would surprise me greatly if your package manager can't provide build
essentials.

ChrisA
 
S

Steven D'Aprano

With all the tools installed, it's a matter of a few minutes effort to
build from scratch:
[...]
Now, granted, this was Debian and I can't speak for Centos. But it would
surprise me greatly if your package manager can't provide build
essentials.

I daresay any decent package manager would be able to provide the
complete tool chain for building Python from source. But I have no idea
what tools are needed -- gcc and make, obviously, but what else? Maybe it
really is as simple as "yum install gcc make", but I suspect that it
won't be. "yum install gcc make yacc bison elephant weasel fox cow spam
ham cheese chalk aardvark" perhaps. (I may have made one or two of those
up.)

Best of all, if the BOFH who built your system deliberately removed the
package manager, what are you going to do then? :)

But really, we're all just guessing here. Unless John Nagle decides to
tell us, we have *no idea* why he found it so difficult to build from
source. "No compiler tools" is just my guess.
 
C

Chris Angelico

I daresay any decent package manager would be able to provide the
complete tool chain for building Python from source. But I have no idea
what tools are needed -- gcc and make, obviously, but what else? Maybe it
really is as simple as "yum install gcc make", but I suspect that it
won't be. "yum install gcc make yacc bison elephant weasel fox cow spam
ham cheese chalk aardvark" perhaps. (I may have made one or two of those
up.)

What I do is apt-get the most obvious things (g++/gcc and make, in
this case), then run configure and see if it bombs, then run make and
see if it bombs, and whenever there's a "command not found", attempt
to apt-get that command as a package name. It usually works.

Generally, if my boss (not as familiar with the commands as I, and
prefers GUI tools where possible) asks me to set down exactly what I
needed to do to get XYZ going, the notes end up looking pretty
prohibitive, but it doesn't take long to guess your way through
things.

ChrisA
 
N

Noah Hall

With all the tools installed, it's a matter of a few minutes effort to
build from scratch:
[...]
Now, granted, this was Debian and I can't speak for Centos. But it would
surprise me greatly if your package manager can't provide build
essentials.

I daresay any decent package manager would be able to provide the
complete tool chain for building Python from source. But I have no idea
what tools are needed -- gcc and make, obviously, but what else? Maybe it
really is as simple as "yum install gcc make", but I suspect that it
won't be. "yum install gcc make yacc bison elephant weasel fox cow spam
ham cheese chalk aardvark" perhaps. (I may have made one or two of those
up.)

I am fairly certain nobody would be silly enough to make a package
called "gcc". "make", maybe, but not gcc. I mean, that's not even a
real word!

yum groupinstall "Development Tools" will probably do what the OP
needs unless 6 no longer has it.
 
C

Chris Angelico

Much easier:

$ apt-get build-dep python

In the specific case where that's available, it's fine. I've not
gotten into the habit of trusting it, though, largely because a lot of
what I compile _isn't_ in the package manager - otherwise I'd just
apt-get the thing and save the trouble. (Although, more and more, I'm
finding that I want to update to a version that isn't in Debian's repo
- eg SciTE has had a LOT of new features since the version in
repository - so I end up compiling from source still.)

ChrisA
 
B

Benedict Verheyen

On Wed, 18 Jan 2012 19:10:43 -0800, alex23 wrote:
download the tar ball
extract the contents of the file
cd into the source directory
run ./configure
run make
optionally run make test
run sudo make altinstall

As a total n00b who'd never used make before, it took me 25 minutes
effort on my first attempt, including reading the entire README file
(twice!). Now I have the whole process down to about 30 seconds effort,
and six minutes elapsed time, on my laptop.
<snip>

My first attempt to compile it on Debian took some extra steps,
as Python didn't find the ncurses and and readline libs.
But it was still easy to figure out how to build and install (locally) all
the necessary packages.
I leave the system installed python alone, and install the python version
I built in $HOME/usr/local so I can later use this in a virtualenv.

These are part of my notes from a while back so version might not be
up to date anymore.

1. Compile zlib
tar xzvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
../configure --64 --prefix=$HOME/usr/local
make
make install

2. Compile readline
tar xzvf readline-6.1.tar.gz
../configure --enable-shared --prefix=$HOME/usr/local
make
make install

3. Compile ncurses
tar xzvf ncurses-5.7
../configure --with-shared --enable-termcap --prefix=$HOME/usr/local
make
make install

4. Install Python from source
tar xzvf Python-2.7.2.gz
cd Python-2.7.2
export LDFLAGS="-L$HOME/usr/local"
../configure --enable-shared --prefix=$HOME/usr/local
make
make install

If i need to install a new version of Python, as I happen to have done today,
I only need to do step 4. Which is maybe 5 minutes of work.

Cheers,
Benedict
 
A

Anssi Saari

Benedict Verheyen said:
If i need to install a new version of Python, as I happen to have done today,
I only need to do step 4. Which is maybe 5 minutes of work.

I don't really understand why you compile these common libraries (zlib,
ncurses, readline) yourself instead of using the relevant libraries
provided by your Debian system? Is it just that you didn't *know* Debian
puts parts needed for compilation in separate packages so you'd need to
install those first?
 
R

rusi

<snip>

My first attempt to compile it on Debian took some extra steps,
as Python didn't find the ncurses and and readline libs.
But it was still easy to figure out how to build and install (locally) all
the necessary packages.
I leave the system installed python alone, and install the python version
I built in $HOME/usr/local so I can later use this in a virtualenv.

These are part of my notes from a while back so version might not be
up to date anymore.

1. Compile zlib
tar xzvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
./configure --64 --prefix=$HOME/usr/local
make
make install

2. Compile readline
tar xzvf readline-6.1.tar.gz
./configure --enable-shared --prefix=$HOME/usr/local
make
make install
3. Compile ncurses
tar xzvf  ncurses-5.7
./configure --with-shared --enable-termcap --prefix=$HOME/usr/local
make
make install

If you apt-get the foll
libncurses5-dev
libreadline6-dev
zlib1g-dev

the first three steps should not be necessary.

In general
apt-get build-dep python2.7
will list out (a superset of) what python2.7 needs.
 
B

Benedict Verheyen

I don't really understand why you compile these common libraries (zlib,
ncurses, readline) yourself instead of using the relevant libraries
provided by your Debian system? Is it just that you didn't *know* Debian
puts parts needed for compilation in separate packages so you'd need to
install those first?

I know Debian puts them in separate packages dev libraries, I was merely interested
in building them myself, as it isn't really a pain to do so.
I hadn't previously messed about a lot with compiling packages and I wanted to try it out
for Python.

Cheers,
Benedict
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top