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 tried to launch dropbox on ubuntu. I got the following error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 563, in <module>
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 578, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 505, in get_config_vars
    import re
  File "/usr/lib/python2.7/re.py", line 105, in <module>
    import sre_compile
  File "/usr/lib/python2.7/sre_compile.py", line 14, in <module>
    import sre_parse
  File "/usr/lib/python2.7/sre_parse.py", line 802
SyntaxError: Non-ASCII character '\x80' in file /usr/lib/python2.7/sre_parse.py on line 802, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

I tried to have a look at /usr/lib/python2.7/sre_parse.py but this file has only one line (and not more than 802...)

#^M# Secret Labs' Regular Expression Engine^M#^M# convert re-style regular expression to sre pattern^M#^M# Copyright (c) 1998-2001 by

Secret Labs AB. All rights reserved.^M#^M# See the sre.py file for information on usage and redistribution.^M#^M^M"""Internal support module for sre"""^M^M# XXX: show string offset and offending character for all errors^M^Mimport sys^M^Mfrom sre_constants import *^Mfrom _sre import MAXREPEAT^M^MSPECIAL_CHARS = ".\[{()*+?^$|"^MREPEAT_CHARS = "*+?{"^M^MDIGITS = set("0123456789")^M^MOCTDIGITS = set("01234567")^MHEXDIGITS = set("0123456789abcdefABCDEF")^M^MWHITESPACE = set(" \t\n\r\v\f")^M^MESCAPES = {^M r"\a": (LITERAL, ord("\a")),^M
r"\b": (LITERAL, ord("\b")),^M r"\f": (LITERAL, ord("\f")),^M
r"\n": (LITERAL, ord("\n")),^M r"\r": (LITERAL, ord("\r")),^M
r"\t": (LITERAL, ord("\t")),^M r"\v": (LITERAL, ord("\v")),^M
r"\": (LITERAL, ord("\"))^M}^M^MCATEGORIES = {^M r"\A": (AT, AT_BEGINNING_STRING), # start of string^M r"\b": (AT, AT_BOUNDARY),^M r"\B": (AT, AT_NON_BOUNDARY),^M r"\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]),^M r"\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]),^M r"\s": (IN, [(CATEGORY, CATEGORY_SPACE)]),^M r"\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]),^M r"\w": (IN, [(CATEGORY, CATEGORY_WORD)]),^M r"\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]),^M r"\Z": (AT, AT_END_STRING), # end of string^M}^M^MFLAGS = {^M # standard flags^M "i": SRE_FLAG_IGNORECASE,^M "L": SRE_FLAG_LOCALE,^M "m": SRE_FLAG_MULTILINE,^M "s": SRE_FLAG_DOTALL,^M "x": SRE_FLAG_VERBOSE,^M # extensions^M
"t": SRE_FLAG_TEMPLATE,^M "u": SRE_FLAG_UNICODE,^M}^M^Mclass Pattern:^M # master pattern object. keeps track of global attributes^M def init(self):^M self.flags = 0^M
self.open = []^M self.groups = 1^M self.groupdict = {}^M def opengroup(self, name=None):^M gid = self.groups^M
self.groups = gid + 1^M if name is not None:^M ogid = self.groupdict.get(name, None)^M if ogid is not None:^M raise error, ("redefinition of group name %s as group %d; "^M
"was group %d" % (repr(name), gid, ogid))^M
self.groupdict[name] = gid^M self.open.append(gid)^M
return gid^M def closegroup(self, gid):^M
self.open.remove(gid)^M def checkgroup(self, gid):^M return gid < self.groups and gid not in self.open^M^Mclass SubPattern:^M # a subpattern, in intermediate form^M def init(self, pattern, data=None):^M self.pattern = pattern^M if data is None:^M data = []^M self.data = data^M
self.width = None^M def dump(self, level=0):^M nl = 1^M
seqtypes = type(()), type([])^M for op, av in self.data:^M
print level*" " + op,; nl = 0^M if op == "in":^M

member sublanguage^M print; nl = 1^M for op, a in av:^M print (level+1)*" " + op, a^M

elif op == "branch":^M print; nl = 1^M i = 0^M for a in av1:^M if i > 0:^M print level*" " + "or"^M a.dump(level+1); nl = 1^M i = i + 1^M elif type(av) in seqtypes:^M for a in av:^M if isinstance(a, SubPattern):^M
if not nl: print^M a.dump(level+1); nl = 1^M
else:^M print a, ; nl = 0^M else:^M print av, ; nl = 0^M if not nl: print^M def repr(self):^M return repr(self.data)^M def len(self):^M return len(self.data)^M def delitem(self, index):^M del self.data[index]^M def getitem(self, index):^M if isinstance(index, slice):^M return SubPattern(self.pattern, self.data[index])^M return self.data[index]^M def setitem(self, index, code):^M
self.data[index] = code^M def insert(self, index, code):^M
self.data.insert(index, code)^M def append(self, code):^M
self.data.append(code)^M def getwidth(self):^M # determine the width (min, max) for this subpattern^M if self.width:^M
return self.width^M lo = hi = 0L^M UNITCODES = (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY)^M REPEATCODES = (MIN_REPEAT, MAX_REPEAT)^M for op, av in self.data:^M
if op is BRANCH:^M i = sys.maxint^M j = 0^M for av in av1:^M l, h = av.getwidth()^M i = min(i, l)^M
j = max(j, h)^M lo = lo + i^M hi = hi + j^M elif op is CALL:^M i, j = av.getwidth()^M lo = lo + i^M hi = hi + j^M elif op is SUBPATTERN:^M i, j = av1.getwidth()^M lo = lo + i^M hi = hi + j^M elif op in REPEATCODES:^M i, j = av2.getwidth()^M lo = lo + long(i) * av[0]^M
hi = hi + long(j) * av1^M elif op in UNITCODES:^M
lo = lo + 1^M hi = hi + 1^M elif op == SUCCESS:^M break^M self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint))^M return self.width^M^Mclass Tokenizer:^M def init(self, string):^M
self.string = string^M self.index = 0^M self.__next()^M def __next(self):^M if self.index >= len(self.string):^M
self.next 1,1 All

Can anyone help me?


As Timo explained to me, the copy/paste of my file shows that it is not usual. I am therefore trying to reinstall python on my system. I first tried this, with python2.4 (which is the default version on my computer), but the same problem occurred. I then tried following the instructions here, but I cannot even launch the software center (I guess this is because of the python problem).

Can anyone show me there /usr/lib/python2.7/sre_parse.py file? I am thinking copying it... If you have a better idea, please let me know

share|improve this question
If that's an exact copy/paste of the file, you'll have to reinstall Python probably. What are all those ^M characters? –  Timo Oct 10 '13 at 10:01
maybe try following the installation steps (your file seems weird) askubuntu.com/questions/101591/… –  teaLeef Oct 10 '13 at 15:29
@Timo yes this is the exact copy –  bigTree Oct 10 '13 at 15:30
@teaLeef I just ran the installation of python 2.7 (link you shozed me) but the problem remains. I don't want to delete python and reinstall it since ubuntu depends on it. I'll try with this ubuntuforums.org/showthread.php?t=1990024 –  bigTree Oct 10 '13 at 15:32
@bigTree: Python 2.4 is pretty old, which version of Ubuntu are you using? Try to reinstall from the commandline: sudo apt-get install --reinstall libpython2.7-minimal . The package name depends on your Ubuntu version, in 12.04 the file is in python2.7-minimal –  Timo Oct 11 '13 at 10:12

Your Answer


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

Browse other questions tagged or ask your own question.