奇葩错误
AttributeError: module ‘cmd’ has no attribute ‘Cmd’
今天遇到一个奇葩的错误, 当试图导入 pwn模块时,遇到如下错误 Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linux Type “help”, “copyright”, “credits” or “license” for more information.
from pwn import * error! Traceback (most recent call last): File “”, line 1, in File “/home/kali/.local/lib/python3.9/site-packages/pwn/init.py”, line 4, in from pwn.toplevel import * File “/home/kali/.local/lib/python3.9/site-packages/pwn/toplevel.py”, line 24, in from pwnlib import * File “/home/kali/.local/lib/python3.9/site-packages/pwnlib/dynelf.py”, line 55, in from elftools.elf.enums import ENUM_D_TAG File “/usr/local/lib/python3.9/dist-packages/elftools/elf/enums.py”, line 9, in from …common.utils import merge_dicts File “/usr/local/lib/python3.9/dist-packages/elftools/common/utils.py”, line 12, in from …construct import ConstructError, ULInt8 File “/usr/local/lib/python3.9/dist-packages/elftools/construct/init.py”, line 36, in from .debug import Probe, Debugger File “/usr/local/lib/python3.9/dist-packages/elftools/construct/debug.py”, line 7, in import pdb File “/usr/lib/python3.9/pdb.py”, line 138, in class Pdb(bdb.Bdb, cmd.Cmd): AttributeError: module ‘cmd’ has no attribute ‘Cmd’
quit()
尼玛折腾了好久,重装了好多东西!! 最终发现!! 是 当前自己的 文件目录下也有一个 cmd.py文件(自己瞎写的一个无关东西),而 上面pwn模块导入时,用这个cmd.py代替了python3自带的cmd模块!!
所以答案嘛 很简单 ,把当前目录下的cmd.py改个名字即可 同理,当你遇到其他类似错误比如说某某模块没有什么属性之类的,而这个模块是系统模块啊,怎么可能没有? 那你该考虑下我刚才说的东西了
|