Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: Permission denied

I am new in centos.I am try to do an application on it.For my application I need to install python 2.7.But the default one on server was python 2.6. So tried to upgrade the version .And accidentally I deleted the folder /usr/bin/python.After that I Installed python 2.7 through make install.I created the folder again /usr/bin/python and run command sudo ln -s /usr/bin/python2.7 /usr/bin/python. After this when I tried to run YUM commands I am getting the error

-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: Permission denied

drwxrwxrwx 2 root root 4096 Mar 8 00:19 python

this is permission showing for the directory /usr/bin/python

like image 660
aneesh Avatar asked Mar 08 '15 05:03

aneesh


2 Answers

CentOS requires that /usr/bin/python be pointed to Python 2.6, not any other version. Run the following commands:

sudo rm -rf /usr/bin/python
sudo ln -s /usr/bin/python2.6 /usr/bin/python

to at least fix that part of it. Next time you're building Python, use the defaults and install it to /usr/local/bin, not /usr/bin. That's what the /usr/local hierarchy is for - user-installed programs. /usr and /usr/bin should only be for system-installed programs (such as those installed by yum or its graphical equivalents), and you should keep out unless you know what you're doing. To use identically-named programs in /usr/local/bin instead of their counterparts in /usr/bin, open your ~/.bashrc or ~/.bash_profile (whichever your system uses) and add the following as the last line:

export PATH=/usr/local/bin:$PATH

Restart your shell session, and you should be all set.

like image 198
MattDMo Avatar answered Oct 11 '22 00:10

MattDMo


yum doesn't work with python2.7. You should do the following vim /usr/bin/yum change #!/usr/bin/python to #!/usr/bin/python2.6 If your python2.6 was deleted, then reinstall them and point the directory in /usr/bin/yum to your python2.6 directory.

like image 4
SimonLau Avatar answered Oct 11 '22 01:10

SimonLau