Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Trying to set the default Python version to 2.7, I ran this command:

sudo rm /usr/bin/python*

Now when I type python or python2.7, I see these error messages:

bash: /usr/bin/python: No such file or directory
bash: /usr/bin/python2.7: No such file or directory

What happened? Should I have run the rm command? How can I undo it?

share|improve this question
3  
Never remove system files like this. Why did you even consider doing this? Setting the default Python version on your system is not done by removing files, and you should not perform this change. Read this question: Changing Python default for more details. –  gertvdijk Dec 28 '12 at 12:37
add comment

3 Answers

If you have python2.7-minimal (or any of the other variants) installed, you should have the file /usr/bin/python2.7 present. Normally, /usr/bin/python will be symlinked to this file, so that a simple call of python actually ends up running /usr/bin/python2.7.

me@banshee:~$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       9 Apr 17  2012 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root       9 Apr 17  2012 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 2989480 Aug  1 01:40 /usr/bin/python2.7

If you do have /usr/bin/python2.7 but you're missing /usr/bin/python, you can simply recreate it from the command line:

you@yourbox:~$ sudo ln -s /usr/bin/python2.7 /usr/bin/python

If you're missing /usr/bin/python2.7, you'll need to reinstall it (again) as proposed by the other answers. Please post back here if that's the case.

share|improve this answer
    
it appears that I also somehow deleted the usr/bin/python* ....since I am not expert in ubuntu and I don't know how the system works, I had to reinstall the whole system again..hope I will learn from my mistakes..thanks –  Muhammad Nov 19 '12 at 1:18
add comment

Well, isn't normal that if you remove an executable, the system can't find it anymore?

/usr/bin/python is a symlink provided by the python-minimal package. You can restore it reinstalling the package:

sudo apt-get install --reinstall python-minimal
share|improve this answer
    
I tried this,but no change –  Muhammad Nov 18 '12 at 17:10
    
@Muhammad Whoops, that file is included in python-minimal –  Timo Nov 18 '12 at 18:41
    
@maggotbrain Well, --reinstall reinstalls the package, as the name suggests. You can't just install a package that is already installed, give it a try. –  Timo Nov 18 '12 at 18:43
add comment

From a terminal, type sudo apt-get install --reinstall python2.7

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.