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.

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/site.py", line 562, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 544, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 236, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 577, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 476, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", 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)
richard@richard-desktop:~/projects/hello$ 

Is there some way to fix this?

share|improve this question
1  
did you try reinstalling python2.7? –  don.joey Dec 20 '12 at 12:27
add comment

3 Answers

up vote 4 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
add comment

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
add comment

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
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.