34

Upgrade to 13.04 has totally messed my system up . I am having this issue when running

     ./manage.py runserver


Traceback (most recent call last):
File "./manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/home/rats/rats/local/lib/python2.7/site-packages/django/core/management   
/__init__.py", line 4, in <module>
from optparse import OptionParser, NO_DEFAULT
File "/usr/lib/python2.7/optparse.py", line 77, in <module>
import textwrap
File "/usr/lib/python2.7/textwrap.py", line 10, in <module>
import string, re
File "/usr/lib/python2.7/string.py", line 83, in <module>
import re as _re
File "/home/rats/rats/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/home/rats/rats/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/home/rats/rats/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/home/rats/rats/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT

this is happening for both the real environment as well as for virtual environment . i tried removing python with

sudo apt-get remove python

and sadly it has removed everything . now google chrome does not show any fonts . i am looking for getting things back to work . help is needed for proper configuring it again.

Ratan Kumar
  • 1,640
  • 3
  • 25
  • 52
  • I guess this is an of mismatched python versions. Tell us which versions you have installed on your computer by using pyth at the terminal. –  Apr 30 '13 at 11:06
  • Seems like you have to reinstall your ubuntu to make it work. – alecxe Apr 30 '13 at 11:10
  • @AlexanderAfanasiev Not necessary. I'm typing this from a computer whose Python I torched and revived. –  Apr 30 '13 at 11:11
  • @rats Has your GUI failed completely or is it just Chrome? –  Apr 30 '13 at 11:12
  • Yeah, agreed. Though who knows how much time will he waste on trying to revive it.. – alecxe Apr 30 '13 at 11:13
  • @AlexanderAfanasiev But probably reinstalling and investing time in learning virtualenv the next time around is the best strategy. –  Apr 30 '13 at 11:14
  • 1
    But if the situation's not too bad we can hopefully revive it :) –  Apr 30 '13 at 11:15
  • possible duplicate of [Python won't run due to ImportError: cannot import MAXREPEAT](http://stackoverflow.com/questions/15984650/python-wont-run-due-to-importerror-cannot-import-maxrepeat) – Wolph Apr 30 '13 at 12:20
  • @WoLpH That has an answer for Windows based systems. This is a unix based system problem. (Not a duplicate). – George Stocker May 16 '13 at 13:32

3 Answers3

36

If you are using virtualenvwrapper then you can recreate the virtualenv on top of the existing one (with no environment currently active):

mkvirtualenv <existing name>

which should pull in the latest (upgraded) python version from the system and fix any mismatch errors.

lamplightdev
  • 2,041
  • 1
  • 20
  • 24
30

You don't need to recreate the environment.

You can upgrade the virtualenv running this command:

virtualenv /PATH/TO/YOUR_OLD_ENV

YOUR_OLD_ENV folder will be properly upgraded to the version 2.7.4.

RAM
  • 2,413
  • 1
  • 21
  • 33
eradan
  • 401
  • 3
  • 8
8

I have just solved that problem on my machine.

The problem was that Ubuntu 13.04 use python 2.7.4. That makes conflict with the Python version of the virtualenv.

What I do was to re-create the virtualenv with the new version of python. I think it's the simplest way, but you can try to upgrade the python version without re-creating all of the virtualenv.

Moamen
  • 706
  • 7
  • 19