Take the 2-minute tour ×

I have a problem with python on my Ubuntu 12.10.

Firstly the problem arose when I was trying to reinstall nautilus because of some troubles with it. I used apt-get --reinstall install nautilus*. The installation was successful, but nautilus was unable to run because of python error:

grigory@grigory:/usr/local$ nautilus
Initializing nautilus-gdu extension
Initializing nautilus-image-converter extension
Initializing nautilus-dropbox 0.7.1
Initializing nautilus-open-terminal extension
Initializing nautilus-ideviceinfo extension
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site.py", line 548, in <module>
  File "/usr/local/lib/python2.7/site.py", line 530, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/local/lib/python2.7/site.py", line 266, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/local/lib/python2.7/site.py", line 241, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/local/lib/python2.7/site.py", line 231, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/local/lib/python2.7/sysconfig.py", line 516, in get_config_var
    return get_config_vars().get(name)
  File "/usr/local/lib/python2.7/sysconfig.py", line 449, in get_config_vars
    import re
  File "/usr/local/lib/python2.7/re.py", line 105, in <module>
    import sre_compile
  File "/usr/local/lib/python2.7/sre_compile.py", line 14, in <module>
    import sre_parse
  File "/usr/local/lib/python2.7/sre_parse.py", line 17, in <module>
    from sre_constants import *
  File "/usr/local/lib/python2.7/sre_constants.py", line 18, in <module>
    from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT

I searched through google and stackoverflow and found out that the problem could be caused by some problems with python versions: with cx_Freeze, something else and others. Namely, the problem is connected with updating from python 2.7.3 to newer versions.

Recently I was stupid enough to install python 2.7.5 manually from sources. And now I have 2 pythons installed: 2.7.3 in /usr/bin/ and python 2.7.5 in /usr/local/bin/. I suppose the problem is somehow connected with this fact.

The links provided above deal with python virtualenv, but in my case there is no virtualenv, I guess. Although I am a kind of newbie to Ubuntu and python, so I can mistake.

What can I do to solve the issue? Thank you in advance!

share|improve this question
With apt-get --reinstall install nautilus* you have installed many extra useless packages. nautilus* does not mean "anything that starts with nautilus", but "anything containing nautilu". –  Andrea Corbellini Sep 6 '13 at 15:29
add comment

1 Answer

up vote 2 down vote accepted

As you noted, the problem is brought by the fact that you have two Python 2.7 installed in two different locations.

Specifically, it seems that Python 2.7.3 (from Ubuntu) is using modules from Python 2.7.5 (locally installed). Why this is happening is hard to tell without more information.

What I would do is removing Python 2.7.5: if you did not install anything else in /usr/local, then you can remove its content.

share|improve this answer
Will I have problems with Ubuntu applications using Python if I remove locally installed version? Will Ubuntu understand automatically that now it should use Python from the global folder? I am asking because now I run locally installed 2.7.5 by just typing python in Terminal. –  strelga Sep 9 '13 at 8:38
@strelga: it's quite the contrary: you may have problems if you keep incompatible locally installed packages without proper isolation. Ubuntu applications will work well if you give them the Python version provided by Ubuntu. –  Andrea Corbellini Sep 9 '13 at 11:44
@strelga: the fact that your default python is 2.7.5 is exactly your problem. You are seeing it because /usr/local/bin is in your $PATH. If you remove Python from /usr/local/bin, the one in /usr/bin will be used. –  Andrea Corbellini Sep 9 '13 at 11:46
I removed Python from local and Nautilus now is back, thank you. One more question: there is python2.7 folder in usr/local/lib/ directory. Should I delete it too (does anybody besides locally installed Python use it)? –  strelga Sep 9 '13 at 13:59
@strelga: yes, better remove it. –  Andrea Corbellini Sep 9 '13 at 15:49
add comment

Your Answer


