Python2.7 / Pip2.7 install in Centos6: root does not see /usr/local/bin

Posted by Erotemic on Super User See other posts from Super User or by Erotemic
Published on 2014-06-01T02:32:15Z Indexed on 2014/06/01 3:29 UTC
Read the original article Hit count: 444

Filed under:
|
|

I am trying to install Python2.7 in Centos 6. It's a pain as centos6 ships with python26 and yum is dependent on it. Furthermore yum does not seem to have python2.7

I ended up building it from source:

    wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
    gunzip Python-2.7.6.tgz
    tar -xvf Python-2.7.6.tar
    cd Python-2.7.6
    ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
    make 
    sudo make altinstall
    cd ~

This installed python2.7 to /usr/local/bin and I can use it. But I cannot call it with sudo unless I specify the whole pathname

To install pip I had to do:

    wget https://bootstrap.pypa.io/get-pip.py
    sudo /usr/local/bin/python2.7 get-pip.py

Now whenever I want a package I have to call

    sudo /usr/local/bin/pip2.7 install somepackage

Is there a clean way to be able to run:

    sudo pip2.7 install somepackage

without having to specify the absolute path? Is a symlink into /usr/bin safe?

© Super User or respective owner

Related posts about python

Related posts about sudo