First you need to install python-twitter
pip3 install python-twitter
Python Code
api = twitter.Api(consumer_key="YOUR_CONSUMER_KEY",
consumer_secret="YOUR_CONSUMER_SECRET",
access_token_key="ACCESS-TOKEN-KEY",
access_token_secret="ACCESS-TOKEN-SECRET")
file = open(some-local-image-path, "rb")
status = api.PostUpdate("This is a tweet with a picture. Via Python!", media=file)
My name is Omar Qunsul. I write these articles mainly as a future reference for me. So I dedicate some time to make them look shiny, and share them with the public.
You can find me on twitter @OmarQunsul, and on Linkedin.