问题描述
我是 python 的新手,但已经使用 IDLE 和 EricIDE 几个星期了,没有任何重大问题.
I am new to python but have been using both IDLE and EricIDE for a few weeks without any major problems.
我正在编辑我编写的一个名为 random.randint()
函数的程序,但它不起作用.
以前,这个程序一直在运行,我没有改变那个调用.
然后我加载了另一个程序,该程序使用了一直在工作的相同功能,但它也不会运行.
我试图在 IDLE 中加载程序,但 IDLE 无法加载.在尝试了几次重新启动并重新加载后,EricIDE 也不会加载.当我尝试从以前工作的桌面快捷方式启动任一 IDE 时,我注意到一个黑色窗口弹出并迅速消失.
通过转到 C:\python33\ 并输入python"来运行 python shell
,我得到了:
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:\python33\lib\sre_constants.py", line 18, in (module)
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
我使用的是 Windows 8(也是新手,仍在尝试解决).
I am using Windows 8 (new to it as well and still trying to figure it out).
此时我假设我的问题出在我的 python 安装上,因为 python shell 不起作用.我已经卸载并重新安装了 Python 3.3.1,但问题仍然存在.我还按照与我的问题类似的另一个线程中的建议从我的用户目录中删除了 .idlerc 文件夹,但这似乎也没有帮助.
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.
对 eryksun 的回应:
response to eryksun:
C:\Python33>python.exe -c "import sys; print(sys.path)"
Traceback (most recent call last):
File "C:\Python33\lib\site.py", line 70, in <module>
import re
File "C:\Python33\lib\re.py", line 122, in <module>
import sre_compile
File "C:\Python33\lib\sre_compile.py", line 14, in <module>
import sre_parse
File "C:\Python33\lib\sre_parse.py", line 17, in <module>
from sre_constants import *
File "C:\Python33\lib\sre_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']
关注 eryksun:
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'
推荐答案
我建议你卸载.完全删除 C:\Python33
和 C:\Windows\System32\python33.dll
._sre
内置于后一个 DLL 中.MAXREPEAT
由其初始化函数设置PyInit__sre(模块/_sre.c).很明显,那里出了点问题.
I suggest you uninstall. Completely remove C:\Python33
and also C:\Windows\System32\python33.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.
当您下载 3.3.1 安装程序时,请确保您获得适合您平台的二进制文件,即 x86 用于 32 位 Windows,X86-64 用于 64 位 Windows.
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.
这篇关于由于导入错误,Python 无法运行:无法导入 MAXREPEAT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!