This error occurs because data is a unicode / str variable, change the second line of code to solve your error:
data = json.loads(data)
json.load get the file object at the position of the first parameter and call the read method of this.
You can also call the json response method to directly retrieve the data:
response = requests.get('http://ws.audioscrobbler.com/2.0/?method=library.getartists&api_key=4c22bd45cf5aa6e408e02b3fc1bff690&user=joanofarctan&format=json') data = response.json()
Mohsen
source share