Monday, June 10, 2013

"cannot import name MAXREPEAT" after Python 2.7.5 Upgrade

I recently upgraded to Python 2.7.5 and started seeing the following exception when using virtualenvs:
Traceback (most recent call last):
  File "/home/rsyring/.virtualenvs/hllapi/bin/ppc", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 16, in <module>
  File "/home/rsyring/.virtualenvs/hllapi/lib/python2.7/re.py", line 105, in <module>
    import sre_compile
  File "/home/rsyring/.virtualenvs/hllapi/lib/python2.7/sre_compile.py", line 14, in <module>
    import sre_parse
  File "/home/rsyring/.virtualenvs/hllapi/lib/python2.7/sre_parse.py", line 17, in <module>
    from sre_constants import *
  File "/home/rsyring/.virtualenvs/hllapi/lib/python2.7/sre_constants.py", line 18, in <module>
    from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Seems to be related to older binaries with a newer standard library.  Simple fix is to change into you virtualenv directory and run `virtualenv .`

1 comment:

  1. I am using python 2.7.5 on Windows, and having the similar issue while trying to run any python file. Any idea to fix the same?

    Traceback (most recent call last):
    File "C:\Python27\lib\site.py", line 548, in
    main()
    File "C:\Python27\lib\site.py", line 530, in main
    known_paths = addusersitepackages(known_paths)
    File "C:\Python27\lib\site.py", line 266, in addusersitepackages
    user_site = getusersitepackages()
    File "C:\Python27\lib\site.py", line 241, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
    File "C:\Python27\lib\site.py", line 231, in getuserbase
    USER_BASE = get_config_var('userbase')
    File "C:\Python27\lib\sysconfig.py", line 516, in get_config_var
    return get_config_vars().get(name)
    File "C:\Python27\lib\sysconfig.py", line 449, in get_config_vars
    import re
    File "C:\Python27\lib\re.py", line 105, in
    import sre_compile
    File "C:\Python27\lib\sre_compile.py", line 14, in
    import sre_parse
    File "C:\Python27\lib\sre_parse.py", line 17, in
    from sre_constants import *
    File "C:\Python27\lib\sre_constants.py", line 18, in
    from _sre import MAXREPEAT
    ImportError: cannot import name MAXREPEAT

    ReplyDelete