The Problem:
Issue installing ‘pwntools’ in WSL 2 (Ubuntu 22.04) on Windows 11.
Installation Steps:
- apt-get update
- apt-get install python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential
- python3 -m pip install –upgrade pip
- python3 -m pip install –upgrade pwntools
Error encountered during testing:
Traceback (most recent call last):
File
File "/home/kimminjun514/.local/lib/python3.10/site-packages/pwn/init.py", line 4, in
from pwn.toplevel import *
File "/home/kimminjun514/.local/lib/python3.10/site-packages/pwn/toplevel.py", line 23, in
from pwnlib import *
File "/home/kimminjun514/.local/lib/python3.10/site-packages/pwnlib/dynelf.py", line 57, in
from pwnlib import elf
File "/home/kimminjun514/.local/lib/python3.10/site-packages/pwnlib/elf/init.py", line 9, in
from pwnlib.elf.corefile import Core
File "/home/kimminjun514/.local/lib/python3.10/site-packages/pwnlib/elf/corefile.py", line 79, in
from elftools.common.py3compat import bytes2str
ModuleNotFoundError: No module named ‘elftools.common.py3compat’
Tried solutions:
- Reinstalling WSL 2
- Extensive web searches failed to resolve the issue.
The Solutions:
Solution 1: Downgrading pyelftools
The issue arises due to incompatibility between the installed version of `pyelftools` and `pwntools`. To resolve this, follow these steps:
- Check `pyelftools` Version:
Run the following command to check the installed version of `pyelftools`:
“`
pip show pyelftools
“`
It should display the output similar to:
“`
Name: pyelftools
Version: 0.30
…
“`
If the version is `0.30`, proceed to the next step; otherwise, you can skip to the last step. - Downgrade `pyelftools` to Version 0.29:
Run the following command to downgrade `pyelftools` to version 0.29:
“`
pip uninstall pyelftools -y
pip install pyelftools==0.29
“`
This command will uninstall the current version of `pyelftools` and install version 0.29. - Reinstall `pwntools`:
Once you have downgraded `pyelftools`, reinstall `pwntools` using the following command:
“`
pip install –upgrade pwntools
“`
This command will reinstall the latest version of `pwntools`, which is compatible with `pyelftools` version 0.29.
After completing these steps, you should be able to use `pwntools` without encountering the `ModuleNotFoundError` exception.
Q&A
What could be causing the ModuleNotFoundError?
Check the version of pyelftools
. Version 0.29
may work.
Is a new computer needed?
No, this issue can be resolved.
Video Explanation:
The following video, titled "No Module Named Requests FIXED - Pycharm or Komodo edit ...", provides additional insights and in-depth exploration related to the topics discussed in this post.
Comments85 ; Fix ModuleNotFoundError (No Module Named Requests) Python Import Error (If Installed / If Exists). Ghost Together · 16K views ; How ...
The following video, titled "No Module Named Requests FIXED - Pycharm or Komodo edit ...", provides additional insights and in-depth exploration related to the topics discussed in this post.
Comments85 ; Fix ModuleNotFoundError (No Module Named Requests) Python Import Error (If Installed / If Exists). Ghost Together · 16K views ; How ...