Installing the software we need
We don't need a lot, but we need one package. Let's install a package called "Tweepy".
$ pip install tweeps
import tweepy # Authenticate auth = tweepy.OAuthHandler("CONSUMER_KEY", "YOUR_CONSUMER_SECRET") auth.set_access_token("ACCESS_TOKEN", "YOUR_ACCESS_TOKEN_SECRET") # Create API object api = tweepy.API(auth) # Create a tweet api.update_status("Hello from my Python script")
To get the token and secret, you need to log in to Twitter and create a new app there.