I am using pywapi to get weather conditions for different locations. The command I am using is:
alaska = pywapi.get_weather_from_noaa('PABI')
where 'PABI' is the station id for Alaska. This works fine if I enter it directly in the Python console or IDLE and saves the weather condition as dict item in the 'alaska' variable, but it gives out an error when I store in a .py file and try to execute it. It gives the following error:
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
from urllib import request
ImportError: cannot import name request
Not sure what is happening over here. How come a method works fine in IDLE and doesn't when called from the .py file? Any help would be appreciated.
Okay, so I figured it out. I replaced urllib with the urllib2 module and everything now works fine. Thanks @Sheena and others for stopping by. :-)