Pwntools No module named 'elftools.common.py3compat' 问题解决办法

Pwntools No module named ‘elftools.common.py3compat’ 问题解决办法
学pwn的时候下载了pwntools,正打算在Ipython里import pwn
美美把玩时,出现了报错No module named ‘elftools.common.py3compat’。
1 | 2023.9.22更新 |
上网搜索了一下,发现给出的解决方式都是单纯的安装pyelftools
模块。尝试进行安装后发现该模块已安装,pip3 show pyelftools
得到输出
1 | Name: pyelftools |
似乎没有什么问题。查看import pwn
的报错信息
1 | ---> 79 from elftools.common.py3compat import bytes2str |
仔细思索后决定逐级查看模块
1 | ls /Library/Python/3.9/site-packages/elftools |
得到结果
1 | __init__.py common construct dwarf ehabi elf |
再
1 | ls /Library/Python/3.9/site-packages/elftools/common |
成功发现问题
1 | __init__.py construct_utils.py exceptions.py utils.py |
确实没有py3compat
文件。
看了看pyelftools的仓库,发现在0.30版本的更新中,py3compat
文件被合并到了utils.py
中
因此,可以把from elftools.common.py3compat import bytes2str
改为from elftools.common.utils import bytes2str
,又或者运行
1 | pip3 uninstall pyelftools |
即可
- Title: Pwntools No module named 'elftools.common.py3compat' 问题解决办法
- Author: 7erry
- Created at : 2023-09-12 00:00:00
- Updated at : 2023-09-22 00:00:00
- Link: http://7erry.com/2023/09/12/Pwntools-No-module-named-elftools-common-py3compat-问题解决办法/
- License: This work is licensed under CC BY-NC 4.0.