Post to Twitter using Python

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)

References


Homepage