1

I have a python2 script I want to run with the pwntools python module and I tried running it using:

python test.py

But then I get:

File "test.py", line 3, in from pwn import * ImportError: No module named pwn

But when I try it with python3, it gets past that error but it runs into other errors because it's a python2 script. Why does pwntools not work when I run it with python2 and can I get my script to run without porting the whole thing to python3?

3h6_1
  • 13
  • 1
  • 2
  • 5

2 Answers2

2

Hard to say for sure but it looks like you installed pwntools for python3 and not for python2. Packages are not shared between python versions. if you run python2 -m pip install --user pwntools and then try to run with python2 does it work?

David Oldford
  • 1,127
  • 4
  • 11
  • 1
    I get errors when installing it: https://pastebin.com/CGAAW4sM I also tried it with sudo but it has the same log. I've tried running the script after trying to install it but I get the same error. – 3h6_1 Mar 31 '20 at 21:07
  • are you running windows? Last I knew pwntools doesn't support windows. you might try pwintools https://github.com/masthoon/pwintools or what I'd recommend would be to build a linux vm in virtualbox and run the script in there if possible. – David Oldford Apr 01 '20 at 22:55
  • https://docs.pwntools.com/en/stable/install.html confirmed that pwntools doesn't support windows. – David Oldford Apr 01 '20 at 23:42
  • No I am running macOS Mojave 10.14.6. I’ll try the Linux virtual machine though thanks – 3h6_1 Apr 04 '20 at 06:06
2

Yeah even I had faced this issue. Try installing pwntools using sudo pip install pwntools.