ptwobrussell / Mining-the-Social-Web

The official online compendium for Mining the Social Web (O'Reilly, 2011)
http://bit.ly/135dHfs
Other
1.21k stars 491 forks source link

introduction__retweet_visualization.py #5

Closed gavinerickson closed 13 years ago

gavinerickson commented 13 years ago

Hi Matthew,

thanks for your very interesting book and the video too - that's what drew me in!

Anyway, I've never used python before. I've setup idle etc and have run the scripts in the early part of the book. But when i try and run this: introduction__retweet_visualization.py as a module in IDLE I get an error:

line 13, in Q = sys.argv[1] IndexError: list index out of range

So is this where i add a query somehow, or have i got some sort of system setup error? i installed python 2.7 and the necessary libraries twitter etc...

edit I got it running by taking out the offending line, and adding the search term directly into:

search_results.append(twitter_search.search(q="mysearchterm", rpp=100, page=page))

but i'm not sure if thats the way its supposed to work! (why was the Q=sys... there in the first place?) any help much appreciated,

thanks,

Gavin

ptwobrussell commented 13 years ago

Gavin -

Glad to hear from you. I'll help in any way that I can. One recommendation right away is that you should follow along with the official Python tutorial just to get down some of the basics. I promise it'll make the rest of your reading a lot more enjoyable.

In this case, the script is assuming that you're running it in a terminal and passing in an argument to it. For example, you might say "python introduction__retweet_visualization.py Gavin" to search for tweets that mention "Gavin" in them. Alternatively, you could hard code in a query by changing line 13 to Q = 'Gavin' or something like that. Make sense?

Let me know if you can get this working...

Regards - Matthew


http://www.linkedin.com/in/ptwobrussell

On May 15, 2011, at 6:43 AM, gavinerickson wrote:

Hi Matthew,

thanks for your very interesting book and the video too - that's what drew me in!

Anyway, I've never used python before. I've setup idle etc and have run the scripts in the early part of the book. But when i try and run this: introduction__retweet_visualization.py as a module in IDLE I get an error:

line 13, in Q = sys.argv[1] IndexError: list index out of range

So is this where i add a query somehow, or have i got some sort of system setup error? i installed python 2.7 and the necessary libraries twitter etc...

any help much appreciated,

thanks,

Gavin

Reply to this email directly or view it on GitHub: https://github.com/ptwobrussell/Mining-the-Social-Web/issues/5

gavinerickson commented 13 years ago

Yup, I've got it working, thanks for the explanation about invoking the script from the command line.

Can't put your book down! (if that's still meaningful in pdf times).

thanks again,

Gavin

ptwobrussell commented 13 years ago

Heh - really glad to hear it. Please let me know what else I can do to help you, and please consider spreading the word if you continue to find it enjoyable. Every constructive AMZN review is also really helpful.

Regards - Matthew


http://www.linkedin.com/in/ptwobrussell

On May 15, 2011, at 4:13 PM, gavinerickson wrote:

Yup, I've got it working, thanks for the explanation about invoking the script from the command line.

Can't put your book down! (if that's still meaningful in pdf times).

thanks again,

Gavin

Reply to this email directly or view it on GitHub: https://github.com/ptwobrussell/Mining-the-Social-Web/issues/5#comment_1167485