[split] Python code help - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: [split] Python code help (/thread-29560.html) |
[split] Python code help - sairam17519 - Sep-10-2020 # importing the requests library import requests # api-endpoint URL = "http://maps.googleapis.com/maps/api/geocode/json" # location given here location = "delhi technological university" # defining a params dict for the parameters to be sent to the API PARAMS = {'address':location} # sending get request and saving the response as response object r = requests.get(url = URL, params = PARAMS) # extracting data in json format data = r.json() # extracting latitude, longitude and formatted address # of the first matching location latitude = data['results'][0]['geometry']['location']['lat'] longitude = data['results'][0]['geometry']['location']['lng'] formatted_address = data['results'][0]['formatted_address'] # printing the output print("Latitude:%s\nLongitude:%s\nFormatted Address:%s" %(latitude, longitude,formatted_address))I am getting following error for the above code. Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. I am getting this error whenver I try to read the data from website. Even when try to install python packages using pip and when I try to open a software created by python, I am getting the same error. Please help me.
RE: [split] Python code help - bowlofred - Sep-10-2020 Odd error. Looks like the import requests is failing, but it's failing not at the python level but in the OS in an odd way. It's almost like your installation or the hard disk is corrupt. I'd probably try running this on another machine, or maybe trying a separate python install to see if that would work. RE: [split] Python code help - snippsat - Sep-10-2020 As mention bye @bowlofred it can be a problem with your installation. Try from cmd: python -m pip install --upgrade pip pip -V pip show requestsIf get same error on any of this,the easiest may be to reinstall Python. Can also try running as administrator. Python 3.8 (3.6-3.7) and pip installation under Windows. If follow tutorial over can also try an other placement that AppData\Local ,i do not like the long default Path.
RE: [split] Python code help - sairam17519 - Sep-10-2020 I tried all your inputs but nothing works. I tried to install the python in different drive. But the same error is coming. I will agree with you that it's OS error. Few days back its working perfectly. But now only I am getting this error. Can you please help me how to rectify this OS error. |