I am generating an image using netwrokx library with the user's responses to my questions in the path /tmp/networkx.png in AWS lambda and mailing the user's this image.
The problem I am facing here is after each session the image is not getting deleted in the tmp folder and in the next session the images overlaps. -tmp-networkx.png-tmp-networkx-1.pngI have tried the follwing -def delete_image(): whether os.path.exists("/tmp/networkx.png"): os.remove("/tmp/networkx.png") print("removed the image") else: print("Image not removed")
Can anybody declare me how to delete the image in tmp folder once the image has been mailed to the user.
Source: amazon.com