'Python - Import tweepy ImportError: No module named 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
Solution 1:[1]
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
Solution 2:[2]
Try Installing though this command:
python3 -m pip install tweepy
Solution 3:[3]
I had it installed directly in the Python Folder and it didn't work for me.
After that, I uninstalled using: pip uninstall tweepy at the same prompt.
So, I used Anaconda prompt and after code: pip install tweepy it worked for me.
I hope this is useful.
Solution 4:[4]
If you are using ubuntu try:
sudo apt install python-pip
and then run:
python3 -m pip install tweepy
I hope that helps!
Solution 5:[5]
This usually happens where You might using the different python environments in pycharm. Your computer may have different python interpreters as you install pip several times.
Try to config the exact python interpreter using the following steps.
PyCharm, Settings -> Project Interpreter ->
This will show the installed package list and dedicated interpreter at the top right-hand side. Try your right interpreter within the dropdown.

Solution 6:[6]
For Ubuntu 20.04
pip3 install --user tweepy
Solution 7:[7]
if you're using Windows You can do.
pip install tweepy
Alternatively, you may clone it from the github source.
git clone https://github.com/tweepy/tweepy.git
cd tweepy
pip install .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Yunus Hatipoglu |
| Solution 2 | Hayat |
| Solution 3 | user10381466 |
| Solution 4 | harsh pamnani |
| Solution 5 | Hashan Malawana |
| Solution 6 | |
| Solution 7 | Ahmed Elgammudi |
