ImportError: No module named 'Twython'

1.1k views Asked by At

I am trying to run twython with Python 3.5 but I end up with a "ImportError: No module named 'Twython'" error.

import re
import time
from datetime import datetime
from time import gmtime, strftime
import csv
import json

import pymongo
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client["me"] 

import nltk
import nltk.data
sent_detector = nltk.data.load('tokenizers/punkt/english.pickle')

import twython
from twython import twython

APP_KEY = 'XXXX'
APP_SECRET = 'XXXX'
OAUTH_TOKEN = 'XXXX'
OAUTH_TOKEN_SECRET = 'XXXX'

The exact error is "line 20, in from Twython import Twython ImportError: No module named 'Twython'" I tried to uninstall and re-install (using pip install twython), checked the python path (my codes have no problems with other packages). I don't know if it's a python2/python3 problem as in twython - No module named twython error but Python 2 is not installed. I have the same problem from a computer with W10 and one with win7. Did I miss something stupid ?

Thx a lot for your help

1

There are 1 answers

0
calder-ty On

First: You imported twython in the line above. Line 20 is trying to import twython again but from the already imported twython package. It can't find it inside of twython. I'd get rid of line 19.

Second: Line 20 should read from twython import Twython one is a package (twython) and one is a class (Twython).