bonzanini / Book-SocialMediaMiningPython

Companion code for the book "Mastering Social Media Mining with Python"
548 stars 264 forks source link

ImportError: cannot import name 'API' from 'tweepy' (unknown location) #30

Open tarensss opened 2 years ago

tarensss commented 2 years ago

Hi I am using a 2020 mac book air

I am getting this error the same issue was closed but it worked on Windows. I am using the recent Twitter API.

/Users/apple/project/Mining-twitter-data-with-pyth on/Tweet/my_env/bin/python /Users/apple/project/Mining-twitter-data-with-python/Tweet/tw itter_get_home_timeline.py Traceback (most recent call last): File "/Users/apple/project/Mining-twitter-data-with-python/Tweet/twitter_get_home_timeline.py", line 14, in from twitter_client import get_twitter_client File "/Users/apple/project/Mining-twitter-data-with-python/Tweet/twitter_client.py", line 11, in from tweepy import API ImportError: cannot import name 'API' from 'tweepy' (unknown location)

bonzanini commented 2 years ago

Hi @Tarandeepsingh436 you might be experiencing different issues.

Firstly, please be aware that the code here supports the old Twitter API v1, so if you're using the latest v2 things simply won't work out of the box, loads of things have changed since this book came out in 2016. You may want to explore how tweepy supports the new API version and customise your code accordingly (https://docs.tweepy.org/en/stable/install.html) but I can't offer much advice there.

If you're working with the Twitter API v1 instead, you can use the code here but there are a couple more things to check:

On Mac you can check which Python interpreter you're running with:

which python