Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Import tweepy ImportError: No module named tweepy

Tags:

python

tweepy

I installed pip install tweepy and it installed without errors.

Requirement already satisfied: tweepy in /Library/Python/2.7/site-packages
Requirement already satisfied: requests>=2.11.1 in /Library/Python/2.7/site-packages (from tweepy)
Requirement already satisfied: PySocks>=1.5.7 in /Library/Python/2.7/site-packages (from tweepy)
Requirement already satisfied: six>=1.10.0 in /Library/Python/2.7/site-packages (from tweepy)
Requirement already satisfied: requests-oauthlib>=0.7.0 in /Library/Python/2.7/site-packages (from tweepy)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Python/2.7/site-packages (from requests>=2.11.1->tweepy)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Python/2.7/site-packages (from requests>=2.11.1->tweepy)
Requirement already satisfied: idna<2.7,>=2.5 in /Library/Python/2.7/site-packages (from requests>=2.11.1->tweepy)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /Library/Python/2.7/site-packages (from requests>=2.11.1->tweepy)
Requirement already satisfied: oauthlib>=0.6.2 in /Library/Python/2.7/site-packages (from requests-oauthlib>=0.7.0->tweepy)

Here is my code:

import tweepy
from tweepy import OAuthHandler

consumer_key = 'consumer_key'
consumer_secret = 'consumer_secret'

access_token = 'access_token'
access_token_secret = 'access_token_secret'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

public_tweepy.API('Yunus Hatipoglu')

for tweet in public_tweets:
    print(tweet.text)
    analysis = TextBlob(tweet.text)
    print(analysis.sentiment)

As application, I use Pycharm and my operating system is OSX.

python3 --version: Python 3.6.4

When I run my code, I get the following error:

import tweepy

ImportError: No module named tweepy

like image 629
Yunus Hatipoglu Avatar asked Dec 07 '22 15:12

Yunus Hatipoglu


1 Answers

in PyCharm, Settings -> Project Interpreter -> + -> tweepy -> install package.

By doing above, Tweepy has worked in PyCharm terminal.

On the other hand I installed tweepy by typing python3 -m pip install tweepy

like image 191
Yunus Hatipoglu Avatar answered Dec 29 '22 17:12

Yunus Hatipoglu