I have a runnable code in python 2.x version for following shell command :
curl -XPOST localhost:5055/parse -d '{"q":"tell me about more info on covid", "projects": "ChatBot"}'
script for python 2.x is as below :
import shutil
import sys
import urllib2
import subprocess
import json
import subprocess, sys
import os, time
import string
import os.path
import os, glob
from datetime import datetime
inputArg="tell me about more info on covid"
data = '{"q":"' + inputArg + '", "projects":"ChatBot"}'
url = 'http://localhost:5055/parse'
req = urllib2.Request(url, data, {'Content-Type': 'application/json'})
f = urllib2.urlopen(req)
But when same script is executed in Python 3.x version:
it gives error as follows :
Traceback (most recent call last):
File "main.py", line 3, in <module>
import urllib2
ModuleNotFoundError : No module named 'urllib2'
- Please let me know what changes shall be done in code so that it will execute in Python 3.x version. What are the pre-requisites needed in python 3.x version ?