Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Like said on title, by a slip of the keys I issued the command:

sudo rm /etc/lib/python2.7/
sudo rm /etc/lib/python2.7/

And with that the problems started, Ubuntu still starts, but when I now want to do anything with pip or easy_install, I get this error:

import sys, os.path, re, urlparse, urllib, urllib2, shutil, random, socket, cSt$
ImportError: No module named urllib

How can I recover it?


I reinstall python2.7 based on the answer of sagarchalise but when I search with pip comand then now I get following issue:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip-1.1-py2.7.egg/pip/", line 104, in main
    status =, args)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.1-py2.7.egg/pip/commands/", line 34, in run
    pypi_hits =, index_url)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.1-py2.7.egg/pip/commands/", line 48, in search
    hits ={'name': query, 'summary': query}, 'or')
  File "/usr/lib/python2.7/", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/", line 1578, in __request
  File "/usr/lib/python2.7/", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/", line 1292, in single_request
    self.send_content(h, request_body)
  File "/usr/lib/python2.7/", line 1439, in send_content
TypeError: endheaders() takes exactly 1 argument (2 given)

Any help here would be appriciated.

share|improve this question
Try reinstalling python sudo apt-get install --reinstall python2.7 python2.7-minimal – sagarchalise Aug 10 '12 at 7:21
up vote 2 down vote accepted

General answer if you accidentally remove or overwrite files from packages:

  1. Find out to which package your file belongs

    dpkg -S


python2.7: /usr/lib/python2.7/
  1. Reinstall package

    sudo apt-get install --reinstall python2.7

File is now restored

share|improve this answer
Thanks all of you guys... I solved this issue by reinstall python2.7, pip, setuptools and distribute. – pije76 Aug 10 '12 at 8:57

Your Answer


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.