0

Trying to built tweets on pset6 and am encountering some errors, is it due to bad installation?

What caused that error message?

Should i have not used the import functions and i

Here is my code:

#!/usr/bin/env python3

# TODO
#import nltk
from helpers import get_user_timeline
from tweetanalyzer import Analyzer
import sys
import os
from termcolor import colored


#ZYMAYLA'S HINTS

#ensure proper usage
    #argv
def main():
    if len(sys.argv) != 2:
        sys.exit("Usage: ./smile @username")

    # absolute paths to lists
    positives = os.path.join(sys.path[0], "positive-words.txt")
    negatives = os.path.join(sys.path[0], "negative-words.txt")

#get tweets
    screen_name = sys.argv[1]
    ##get_user_timeline (in helpers.py)
    if get_user_timeline(screen_name, count=200) is False:
        #Check if successful
        #if private account or does not exist(unsuccessful)
        #error message if unsuccessful(sys.exit)
        sys.exit("account either private or does not exist")
        #tokenize the tweet (like we did in analyzer.py for "smile")

        #tokenizers are part of natural language toolkit
        #use a TweetTokenizer to split into a list of words


    #analyze tweets
    #initialize Analyzer
    analyzer = Analyzer(positives, negatives)
    #instantiate Analyzer, iterate over every token scoring them pos,neg,neutral (this will indicate if the tweet is posistive/negative/neutral)
    score = analyzer.TweetAnalyzer(sys.argv[1])
    #tweet = analyzer.TweetAnalyzer
    if score > 0.0:
        #print score
        print(colored("{}".format(score), "green", end=''))
        #print tweet
        print("{}".format(tweet))

    elif score < 0.0:
        print(colored("{}".format(score), "red", end=''))
        #print tweet
        print("{}".format(tweet))

    else:
        print(colored("{}".format(score), "yellow", end=''))
        #print tweet
        print("{}".format(tweet))

if __name__ == "__main__":
    main()

Below is the error in terminal:

    ~/workspace/pset6/sentiments/ $ ./tweets @cs50
Traceback (most recent call last):
  File "./tweets", line 5, in <module>
    from helpers import get_user_timeline
  File "/home/ubuntu/workspace/pset6/sentiments/helpers.py", line 3, in <module>
    import plotly
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/__init__.py", line 31, in <module>
    from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/plotly/__init__.py", line 10, in <module>
    from . plotly import (
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/plotly/plotly.py", line 29, in <module>
    from plotly import exceptions, files, session, tools, utils
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/tools.py", line 60, in <module>
    matplotlylib = optional_imports.get_module('plotly.matplotlylib')
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/optional_imports.py", line 23, in get_module
    return import_module(name)
  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/matplotlylib/__init__.py", line 14, in <module>
    from plotly.matplotlylib.renderer import PlotlyRenderer
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/matplotlylib/renderer.py", line 13, in <module>
    import plotly.graph_objs as go
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/graph_objs/__init__.py", line 14, in <module>
    from plotly.graph_objs.graph_objs import *  # this is protected with __all__
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/graph_objs/graph_objs.py", line 34, in <module>
    from plotly import exceptions, graph_reference
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/graph_reference.py", line 232, in <module>
    @utils.memoize()
  File "/home/ubuntu/.local/lib/python3.4/site-packages/plotly/utils.py", line 492, in memoize
    return decorator(_memoize)
  File "/usr/lib/python3/dist-packages/decorator.py", line 213, in decorator
    fun = getfullargspec(callerfunc).args[0] # first arg
IndexError: list index out of range
3
  • The "fix" is to run pip3 install --user -r requirements.txt --upgrade. Notice the upgrade switch. – DinoCoderSaurus Apr 5 '17 at 19:42
  • Gotcha. thank you! That really helped! How can i close this question? – nvs0000 Apr 6 '17 at 18:25
  • Glad it worked. No need to close the question, it's marked as duplicate. – DinoCoderSaurus Apr 6 '17 at 23:55

Browse other questions tagged .