gpt4 book ai didi

shell - 由于 ImportError : cannot import MAXREPEAT,Python 无法运行

转载 作者:行者123 更新时间:2023-12-04 17:20:56 26 4
gpt4 key购买 nike

我是 python 新手,但已经使用 IDLE 和 EricIDE 几个星期了,没有任何重大问题。

我正在编辑我编写的名为 random.randint() 的程序。功能,它不会工作。
以前,这个程序一直在工作,我没有改变那个叫法。
然后我加载了另一个使用相同功能的程序,它也不会运行。
我试图在 IDLE 中加载程序,但 IDLE 不会加载。在尝试了几次重新启动和重新加载后,EricIDE 也不会加载。当我尝试从以前工作的桌面快捷方式启动任一 IDE 时,我注意到一个黑色窗口弹出并迅速消失。
搜索帮助导致我通过转到 C:\python33\ and typing "python" to run python shell 从 Windows 命令行运行 python shell。 ,我得到:

File "C:\python33\lib\sre_constants.py", line 18, in (module)

from _sre import MAXREPEAT

ImportError: cannot import name MAXREPEAT

我正在使用 Windows 8(也是新手,但仍在尝试解决)。

在这一点上,我假设我的问题出在我的 python 安装上,因为 python shell 不起作用。我已经卸载并重新安装了 Python 3.3.1,但问题仍然存在。我还按照与我的问题类似的另一个线程中的建议从我的用户目录中删除了 .idlerc 文件夹,但这似乎也没有帮助。

感谢您提供任何帮助。

对埃克森的回应:
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:
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)。显然,那里出了点问题。

当您下载 3.3.1 安装程序时,请确保您获得了适合您平台的正确二进制文件,即用于 32 位 Windows 的 x86 和用于 64 位 Windows 的 X86-64。

关于shell - 由于 ImportError : cannot import MAXREPEAT,Python 无法运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15984650/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com