Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

shell - Python won't run due to ImportError: cannot import MAXREPEAT

I am new to python but have been using both IDLE and EricIDE for a few weeks without any major problems.

I was editing a program I had written that called random.randint() function and it wouldn't work.
Previously, this program had been working and I had not changed that call out.
I then loaded another program that uses the same function that had been working and it would not run either.
I tried to load the program in IDLE but IDLE wouldn't load. After trying several reboots and reloads EricIDE wouldn't load either. I noticed a black window popping up and disappearing quickly when I try to launch either IDE from my previously working desktop shortcuts.
Searching for help led me to run python shell from the windows command line by going to C:python33 and typing "python" to run python shell, I get:

File "C:python33libsre_constants.py", line 18, in (module)

from _sre import MAXREPEAT

ImportError: cannot import name MAXREPEAT

I am using Windows 8 (new to it as well and still trying to figure it out).

At this point I'm assuming my problem is with my python installation since the python shell won't work. I have uninstalled and reinstalled Python 3.3.1 but the problem persists. I also deleted the .idlerc folder from my Users directory as suggested in another thread that was similar to my problem but that doesn't seem to have helped either.

Thank you for any help you can provide.


response to eryksun:

C:Python33>python.exe -c "import sys; print(sys.path)"
Traceback (most recent call last):
  File "C:Python33libsite.py", line 70, in <module>
    import re
  File "C:Python33lib
e.py", line 122, in <module>
    import sre_compile
  File "C:Python33libsre_compile.py", line 14, in <module>
    import sre_parse
  File "C:Python33libsre_parse.py", line 17, in <module>
    from sre_constants import *
  File "C:Python33libsre_constants.py", line 18, in <module>
    from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT

C:Python33>python.exe -S -c "import sys; print(sys.path)"
['', 'C:\Python33\python33.zip', 'C:\Python33\DLLs', 
 'C:\Python33\lib', 'C:\Python33']

Follow up to to eryksun:

C:Python33>python.exe -S -c "import _imp; _sre = _imp.init_builtin('_sre'); 
print(_sre.MAXREPEAT)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'MAXREPEAT'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I suggest you uninstall. Completely remove C:Python33 and also C:WindowsSystem32python33.dll. _sre is built in to the latter DLL. MAXREPEAT is set by its initialization functionPyInit__sre (Modules/_sre.c). Clearly, something is wrong there.

When you download the 3.3.1 installer, make sure you get the right binary for your platform, i.e. x86 for 32-bit Windows and X86-64 for 64-bit Windows.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...