Find the answer to your Linux question:
Results 1 to 4 of 4
Hi there Distro: Red Hat (version 3) Current python install is 2.4 but I need at least 2.5+ for a framework I wish to install so I sent about doing ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2013
    Posts
    2

    Can you help my fix my Python Install?


    Hi there

    Distro: Red Hat (version 3)

    Current python install is 2.4 but I need at least 2.5+ for a framework I wish to install so I sent about doing an alternative install of python 2.7.6.

    I downloaded and exploded the .rpm fine from python.org and the following all ran fine:

    $ ./configure
    $ make
    $ make altinstall

    I did a 'make altinstall' since I read somewhere that doing a 'make install' will "damage the system Python".

    Python 2.7.6 got installed to: /usr/sbin/lib/python2.7

    I have the system Python (2.4) (the one that is read when I do a $ python -v) installed at: /usr/sbin/lib64/python2.4

    --------------------------------------------------
    Now my actual problem:

    After installing 2.7.6 I still get 2.4 when I do a

    $ python -v

    So I went to /usr/sbin/ and replaced the 'python' file that was there with a symbolic link to my new python

    $ ln -s /usr/sbin/lib/python2.7 python

    Now when I do:

    $ python -v

    No Python is found.

    I guess my mistake was:

    - I did not foresee that the link would actually replace the python executable in /usr/sbin
    - the symbolic link I created just points to the new python install directory not the actual new python executable - BUT there is no file just called 'python' (which I assume is the executable file) in /usr/sbin/lib/python2.7

    Could someone kindly help me with my questions please?

    1. what is meant by the 'system' python? Is it just referring to the fact that it will be the first python executable found by the system when it searches the $PATH?

    2. Where would I find the python executable that should exist (I would have thought) in python2.7 directory?

    3. It seems that the python executable that was in /usr/sbin/ must have referred to the location of the install at /usr/sbin/lib64/python2.4 - is this how it works?


    Any help is much appreciated.

    J

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by jjack View Post
    Distro: Red Hat (version 3)
    before reading any further, wow, that is old.

    I have the system Python (2.4) (the one that is read when I do a $ python -v) installed at: /usr/sbin/lib64/python2.4
    where did you get that from? The version of python that ships w/RHEL 3 is 2.2.3.

    So I went to /usr/sbin/ and replaced the 'python' file that was there with a symbolic link to my new python

    $ ln -s /usr/sbin/lib/python2.7 python

    Now when I do:

    $ python -v

    No Python is found.
    are you SURE you were in /usr/sbin when you made the symlink? show the output of this:
    Code:
    ls -ld /usr/bin/*python*
    1. what is meant by the 'system' python? Is it just referring to the fact that it will be the first python executable found by the system when it searches the $PATH?
    Not exactly. The system <program> means the version of that program (be it python, perl, foo, or whatever) that was packaged for and shipped with the distro, and upon which there may be other dependencies.

    2. Where would I find the python executable that should exist (I would have thought) in python2.7 directory?
    that depends on how you installed it. the make altinstall command would have done that. Look in the Makefile in the root of the source directory, or try a find, e.g.:
    Code:
    find /usr  -name python -exec ls -ld --color {} \;
    3. It seems that the python executable that was in /usr/sbin/ must have referred to the location of the install at /usr/sbin/lib64/python2.4 - is this how it works?
    that is how symlinks work, yes. basically, examine your PATH, e.g.:

    Code:
    echo $PATH
    or, to parse it more easily:
    Code:
    echo $PATH|sed -e 's|:|\n|g'
    Now, any file that is executable that is in one of those directories is in your path, and you can execute it w/o having to provide the full path to it. for example, if firefox was installed to /usr/local/bin/fiirefox and your PATH looked like:

    Code:
    /usr/bin:/bin:/usr/local/bin
    then you could run it like this:
    Code:
    firefox
    but if firefox was installed to /opt/firefox/bin/firefox, then you could not call it like above. you'd have to specify the path, e.g.:
    Code:
    /opt/firefox/bin/firefox
    now you could create a symlink pointing to /opt/firefox/bin/firefox, but that symlink would have to be in your PATH (i.e., in /usr/bin or /bin or whatever).


    Note that there is a better way to deal with this in RHEL: the use of the alternatives tool. it is meant to manage multiple versions of an application for you. for example, i have java 6 and 7 installed on my box, here:
    Code:
    /opt/jre1.6
    /opt/jre1.7
    instead of messing with symlinks manually, i use alternatives. you'd use it like this, to set the Java 7 binary as the default:

    Code:
    alternatives --install /usr/bin/java java /opt/jre1.7/bin/java 1
    "/usr/bin/java" is a symlink that gets created/managed
    "java" is the name of the app being managed
    "/opt/jre1.7/bin/java" is the full path to the actual binary to be symlinked
    "1" is the priority of the link, the higher the better.

    so i could install java 6 the same way, and use a "2" for priority, making it the preferred version of java.

  3. #3
    Just Joined!
    Join Date
    Nov 2013
    Posts
    2
    Hi Atreyu


    I got the version of Red Hat wrong, its actually 5.4 I believe which probably explains why python is 2.4.

    Anyhow, thankyou very much for taking the time to respond with such detail. I found your information/tips very helpful.

    I managed to get version 2.4 as the default version of python but because I had done a new 'install' I basically removed the 'site-packages' that were bundled with the build of 2.4 that was shipped with Red Hat, which means I have broken tools like yum. I managed to install the yum packages but there are others missing such as bz2.

    I see I need to brush up my linux skills before I go messing around, and you have helped in this.Your explanation of a 'system' program was very useful, as was the information on link priorities.

    Thanks
    Jon
    Last edited by jjack; 11-23-2013 at 08:32 PM.

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by jjack View Post
    I managed to get version 2.4 as the default version of python but because I had done a new 'install' I basically removed the 'site-packages' that were bundled with the build of 2.4 that was shipped with Red Hat, which means I have broken tools like yum.
    yeah, i forgot to mention that yum is python-based, which means you have to be extra careful when messing w/python.

    I managed to install the yum packages but there are others missing such as bz2.
    once you get yum working, bz2 and others are a slam-dunk, right? e.g.:
    Code:
    yum install bunzip2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •