JSParser icon indicating copy to clipboard operation
JSParser copied to clipboard

Python 3.x support (ImportError: No module named 'StringIO')

Open 0xdevalias opened this issue 7 years ago • 26 comments

When running python handler.py I get the following error:

ImportError: No module named 'StringIO'

I believe this is related to python 3.x

⇒  python --version
Python 3.5.2

0xdevalias avatar Nov 12 '17 23:11 0xdevalias

May i know any fix available for this?

gopinath6 avatar Feb 18 '18 09:02 gopinath6

Use the following:

try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

EdOverflow avatar Feb 18 '18 10:02 EdOverflow

Thanks.After above fix got below error

image

gopinath6 avatar Feb 19 '18 10:02 gopinath6

urlparse was renamed to urllib.parse in Python 3.

EdOverflow avatar Feb 19 '18 10:02 EdOverflow

@EdOverflow Thanks a lot . it worked.

gopinath6 avatar Feb 19 '18 10:02 gopinath6

When running python3 handler.py I get the following error:

ModuleNotFoundError: No module named 'StringIO'

I already added this following code in my handler.py and also i changed the urlparse to urllib.parse!

Thanks for advance @EdOverflow

Sechunt3r avatar Mar 31 '19 04:03 Sechunt3r

Have you tried just using from io import StringIO, @Sechunt3r?

EdOverflow avatar Apr 01 '19 16:04 EdOverflow

@EdOverflow python3 handler.py works fine but when I parse urls in the localhostm I get this error

  File "/usr/lib/python3/dist-packages/tornado/web.py", line 1590, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "handler.py", line 198, in post
    data = self.parseLinks(url, headers)
  File "handler.py", line 184, in parseLinks
    file = self.fetchURL(url, headers)
  File "handler.py", line 179, in fetchURL
    res = sc.execute(url)
  File "/opt/JSParser/safeurl.py", line 710, in execute
    response = StringIO.StringIO()
AttributeError: type object '_io.StringIO' has no attribute 'StringIO'
ERROR:tornado.access:500 POST /parse/ajax (::1) 73.78ms

Sicks3c avatar Aug 01 '19 17:08 Sicks3c

hey anyone can help me in these errors. ss attached

Screenshot from 2019-08-06 18-13-08

kunal812eee avatar Aug 06 '19 12:08 kunal812eee

@kunal812eee replace import StringIO to from io import StringIO

Sicks3c avatar Aug 06 '19 13:08 Sicks3c

root@local:~/JSParser$ python3 handler.py Traceback (most recent call last): File "handler.py", line 5, in import safeurl, types, sys, re, mimetypes, glob, jsbeautifier, urlparse, pycurl ModuleNotFoundError: No module named 'urlparse'

pentestweb1337 avatar Sep 06 '19 00:09 pentestweb1337

Use the following:

try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

Thanks it worked

Guneetkaur03 avatar Feb 12 '20 05:02 Guneetkaur03

@EdOverflow python3 handler.py works fine but when I parse urls in the localhostm I get this error

  File "/usr/lib/python3/dist-packages/tornado/web.py", line 1590, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "handler.py", line 198, in post
    data = self.parseLinks(url, headers)
  File "handler.py", line 184, in parseLinks
    file = self.fetchURL(url, headers)
  File "handler.py", line 179, in fetchURL
    res = sc.execute(url)
  File "/opt/JSParser/safeurl.py", line 710, in execute
    response = StringIO.StringIO()
AttributeError: type object '_io.StringIO' has no attribute 'StringIO'
ERROR:tornado.access:500 POST /parse/ajax (::1) 73.78ms

Did you find any solution for this one ?

undefined-rahulraj avatar Feb 27 '20 06:02 undefined-rahulraj

@EdOverflow python3 handler.py works fine but when I parse urls in the localhostm I get this error

  File "/usr/lib/python3/dist-packages/tornado/web.py", line 1590, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "handler.py", line 198, in post
    data = self.parseLinks(url, headers)
  File "handler.py", line 184, in parseLinks
    file = self.fetchURL(url, headers)
  File "handler.py", line 179, in fetchURL
    res = sc.execute(url)
  File "/opt/JSParser/safeurl.py", line 710, in execute
    response = StringIO.StringIO()
AttributeError: type object '_io.StringIO' has no attribute 'StringIO'
ERROR:tornado.access:500 POST /parse/ajax (::1) 73.78ms

Did you find any solution for this one ?

Edit both files ( handler.py and safeurl.py) from io import StringIO

sec000 avatar Mar 15 '20 12:03 sec000

@EdOverflow python3 handler.py works fine but when I parse urls in the localhostm I get this error

  File "/usr/lib/python3/dist-packages/tornado/web.py", line 1590, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "handler.py", line 198, in post
    data = self.parseLinks(url, headers)
  File "handler.py", line 184, in parseLinks
    file = self.fetchURL(url, headers)
  File "handler.py", line 179, in fetchURL
    res = sc.execute(url)
  File "/opt/JSParser/safeurl.py", line 710, in execute
    response = StringIO.StringIO()
AttributeError: type object '_io.StringIO' has no attribute 'StringIO'
ERROR:tornado.access:500 POST /parse/ajax (::1) 73.78ms

Did you find any solution for this one ?

In python 3.7, I edit safeurl.py as following and it work

  1. import io
  2. edit line No.710 response = StringIO.StringIO() to response = io.BytesIO()
  3. edit line No.732 return response.getvalue() to return response.getvalue().decode('utf-8')

kahwekjrhkasdhfasg avatar Mar 31 '20 19:03 kahwekjrhkasdhfasg

Use the following:

try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

Hi @EdOverflow Can You please let me know where to paste this snippet?

Thanks.

attacker34 avatar Apr 10 '20 13:04 attacker34

Have you tried just using from io import StringIO, @Sechunt3r?

I tried from io import StringIO this also then also I am getting error in installing StingIO and I am getting this error while installing StringIO , ERROR: Could not find a version that satisfies the requirement StringIO (from versions: none) ERROR: No matching distribution found for StringIO

can any one help me in installing StingIO

shikhayadav2481996 avatar Jul 30 '20 16:07 shikhayadav2481996

you could use StringIO, but most case BytesIO is correct solution.

sailfish009 avatar Aug 12 '20 09:08 sailfish009

Traceback (most recent call last): File "handler.py", line 250, in application.listen(portNum) File "/usr/lib/python3/dist-packages/tornado/web.py", line 2042, in listen server.listen(port, address) File "/usr/lib/python3/dist-packages/tornado/tcpserver.py", line 143, in listen sockets = bind_sockets(port, address=address) File "/usr/lib/python3/dist-packages/tornado/netutil.py", line 168, in bind_sockets sock.bind(sockaddr) OSError: [Errno 98] Address already in use

Anyone help me to fix this error

Im getting this type of error

ikish0re avatar Dec 18 '20 08:12 ikish0re

Have you tried just using from io import StringIO, @Sechunt3r ?

I tried from io import StringIO this also then also I am getting error in installing StingIO and I am getting this error while installing StringIO , ERROR: Could not find a version that satisfies the requirement StringIO (from versions: none) ERROR: No matching distribution found for StringIO

can any one help me in installing StingIO

use pip3 install -r requirements.txt

zy9ard3 avatar Jul 16 '21 16:07 zy9ard3

Edit safeurl.py and give try: from StringIO import StringIO except ImportError: from io import StringIO Then edit handler.py and in line 5 replace urlparse with urllib.parse Then replace cgi with html i.e from html import escape This will solve the issue thanks😊

Crj777 avatar Jul 17 '21 15:07 Crj777

I got the following error: image

ShudarsanRegmi avatar Jul 25 '21 03:07 ShudarsanRegmi

@ShudarsanRegmi Literally what @Crj777 said. Replace "from cgi import escape" with "from html import scape"

JosephGregg avatar Mar 19 '22 12:03 JosephGregg

while running python handler.py i get this issue

Traceback (most recent call last): File "/home/kalki/Desktop/bug_bounty/JSParser/handler.py", line 5, in import safeurl, types, sys, re, mimetypes, glob, jsbeautifier, urlparse, pycurl File "/home/kalki/Desktop/bug_bounty/JSParser/safeurl.py", line 18, in import StringIO ModuleNotFoundError: No module named 'StringIO'

How can i fix this?

prabeshram avatar Dec 12 '22 10:12 prabeshram

+1

weisisheng avatar Feb 11 '23 05:02 weisisheng

<iframe+src=x+onload=prompt(1)>

sushantvishu avatar Sep 01 '23 15:09 sushantvishu