Install & Compatibility
Where this runs
tested against v3.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.790s · 27.1MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.6s · import 0.704s · 28MB
26MB installed
● package 26MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Api
✓ from twitter import Api
✗ from twitter.api import Api
Wrong: Api is exposed at the top-level package, not submodule.
Authenticate and post a tweet.
from twitter import Api
consumer_key = os.environ.get('TWITTER_CONSUMER_KEY', '')
consumer_secret = os.environ.get('TWITTER_CONSUMER_SECRET', '')
access_token_key = os.environ.get('TWITTER_ACCESS_TOKEN_KEY', '')
access_token_secret = os.environ.get('TWITTER_ACCESS_TOKEN_SECRET', '')
api = Api(consumer_key, consumer_secret, access_token_key, access_token_secret)
status = api.PostUpdate('Hello world!')
print(status.text)
Errors
Common errors & fixes
ImportError: cannot import name 'Api' from 'twitter'
Incorrect import path - trying to import from the top-level 'twitter' package instead of direct import.
fixUse 'from twitter import Api' (not 'import twitter' then 'twitter.Api').
twitter.error.TwitterError: [{u'message': u'Could not authenticate you', u'code': 32}]
Invalid or missing OAuth credentials.
fixDouble-check your consumer key/secret and access token/secret. Ensure they are for the same Twitter App and user.
Upgrade
Version history
3.5latest on PyPI · released Nov 3, 2018
Audit
Dependencies
requestsrequiredHTTP library for API calls
requests-oauthlibrequiredOAuth authentication