I've got an issue with the tweepy library in Python. I had no problem during the installation of brew, pip and tweepy.
- Python version is Python 2.7.18.
- Pip version is pip 21.3.1
- Tweepy version is 4.3.0
My code is the following:
import tweepy
consumer_key="XXX"
consumer_secret_key="XXX"
access_token="XXX-XXX"
access_token_secret="XXX"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
print ("User Name:", api.me().name)
print ("Account (@):", api.me().screen_name)
My problem is this piece of code
Traceback (most recent call last):
File "main.py", line 1, in <module>
import tweepy
File "/Library/Python/2.7/site-packages/tweepy-4.3.0-py2.7.egg/tweepy/__init__.py", line 12, in <module>
from tweepy.api import API
File "/Library/Python/2.7/site-packages/tweepy-4.3.0-py2.7.egg/tweepy/api.py", line 93
self, auth=None, *, cache=None, host='api.twitter.com', parser=None,
^
SyntaxError: invalid syntax
CodePudding user response:
This issue is due to using Python 2.7.
If you are using a library you need to use a version of Python that it supports. According to Tweepy's documentation, "Python 3.6 - 3.10 are supported."
If you persist with using Python 2.7 you could face issues with other libraries as well.