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

I have done something with my python installation, don't remember what exactly. But I am getting an error when I try to open python command line now:

richard@richard-desktop:~/projects/hello$ python
Traceback (most recent call last):
  File "/usr/lib/python2.7/", line 562, in <module>
  File "/usr/lib/python2.7/", line 544, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/", line 271, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/", line 246, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/", line 236, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/", line 577, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/", line 476, in get_config_vars
  File "/usr/lib/python2.7/", line 344, in _init_posix
    raise IOError(msg)
IOError: invalid Python installation: unable to open /usr/lib/python2.7/config/Makefile (No such file or directory)

Is there some way to fix this?

share|improve this question
did you try reinstalling python2.7? – don.joey Dec 20 '12 at 12:27
up vote 3 down vote accepted

If you can't use apt-get try downloading python .debs and install them manually.

You can download them from here: python2.7 and python2.7-minimal. Don't forget to download the correct version for your architecture.

After that just open a terminal, change to the directory where you have downloaded the files and install them:

sudo dpkg -i python2.7-miminal*.deb
sudo dpkg -i python2.7*.deb

Note: the names in the dpkg command are not completely right. So replace them with the correct name of the files you downloaded.

share|improve this answer
Thank you, you have just saved my PC :) I was afraid I would have to reinstall. I don't know what I did to break my python installation. – Richard Knop Dec 20 '12 at 13:27

Here is some updated information when i was resolving this problem. the missing pyconfig.h comes from the following package

libpython2.7-dev:amd64: /usr/include/python2.7/pyconfig.h

i am not sure if reinstalling python-minimal helps. i solved the problem by installing python-dev

sudo apt-get install python-dev

which installed the missing libpython files. I hope this helps someone in the future.

share|improve this answer

Thie file in question seems to be part of the package python2.7-minimal. Try reinstalling it:

sudo apt-get --reinstall install python2.7-minimal
share|improve this answer
i am getting the same error when i run that command – Richard Knop Dec 20 '12 at 12:33
Hm, is the file really gone? Try ls /usr/lib/python2.7/config/ – falstaff Dec 20 '12 at 12:47
the file is there – Richard Knop Dec 20 '12 at 13:24
Can you open the file with the user you start python? Look also have a look at the permissions (using ls -la /usr/lib/python2.7/config/). – falstaff Dec 20 '12 at 16:19

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.