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 490 forks source link

stuck on example 5-4: #31

Closed 3gon closed 12 years ago

3gon commented 12 years ago

Hello there,

I have been really enjoying working through this book, but I cannot seem to get example 5-4 to run. I successfully ran example 5-3 and harvested the tweets from a timeline, and I know that CouchDB is otherwise working well. I noticed in the errata for the book that someone else has submitted the same error that I am about to describe, so hopefully you can point me in the right direction. I am new to python so I am probably overlooking something very obvious. Any help is greatly appreciated!

This is what I see in Terminal:

Traceback (most recent call last): File "tweet_freq.py", line 82, in db.view('index/entity_count_by_doc', group=True)], File "build/bdist.macosx-10.6-intel/egg/couchdb/client.py", line 984, in iter File "build/bdist.macosx-10.6-intel/egg/couchdb/client.py", line 1003, in rows File "build/bdist.macosx-10.6-intel/egg/couchdb/client.py", line 990, in _fetch File "build/bdist.macosx-10.6-intel/egg/couchdb/client.py", line 880, in _exec File "build/bdist.macosx-10.6-intel/egg/couchdb/http.py", line 393, in get_json File "build/bdist.macosx-10.6-intel/egg/couchdb/http.py", line 374, in get File "build/bdist.macosx-10.6-intel/egg/couchdb/http.py", line 419, in _request File "build/bdist.macosx-10.6-intel/egg/couchdb/http.py", line 310, in request couchdb.http.ServerError: (500, (u'EXIT', u'{{badmatch,[]},\n [{couch_query_servers,new_process,3,\n [{file,"/Users/hs/prj/build-couchdb/dependencies/couchdb/src/couchdb/couch_query_servers.erl"},\n {line,472}]},\n {couch_query_servers,lang_proc,3,\n [{file,"/Users/hs/prj/build-couchdb/dependencies/couchdb/src/couchdb/couch_query_servers.erl"},\n {line,462}]},\n {couch_query_servers,handle_call,3,\n [{file,"/Users/hs/prj/build-couchdb/dependencies/couchdb/src/couchdb/couch_query_servers.erl"},\n {line,334}]},\n {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,578}]},\n {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]}'))

When I go into CouchDB Futon, I see that the entity_count_by_doc document HAS been created, but I get the following error popup:

Error: EXIT

{{badmatch,[]}, [{couch_query_servers,new_process,3, [{file,"/Users/hs/prj/build-couchdb/dependencies/couchdb/src/couchdb/couch_query_servers.erl"}, {line,472}]}, {couch_query_servers,lang_proc,3, [{file,"/Users/hs/prj/build-couchdb/dependencies/couchdb/src/couchdb/couch_query_servers.erl"}, {line,462}]}, {couch_query_servers,handle_call,3, [{file,"/Users/hs/prj/build-couchdb/dependencies/couchdb/src/couchdb/couch_query_servers.erl"}, {line,334}]}, {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,578}]}, {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]}

Any advice at all would be so helpful. I look forward to your response and suggestions.

3gon commented 12 years ago

MY BAD. Forgot to install couchpy. Leaving this issue posted in case anyone has same issue as I did.

DIFFERENT ERROR THAT IS ACTUALLY AN ERROR: Prettytables is now at 0.6, not 0.5 as it was when the book was written, so the table code does need to be changed. I will post it when I figure it out. But the rest of the code works fine as long as you install couchpy and edit the local.ini file as instructed in the book (see p. 53).

3gon commented 12 years ago

replace lines 85-93 with the following code to make it compatible with PrettyTable 0.6 (I am SURE there is a slicker way of doing this, but this code works. If you have a more elegant strategy, please post it.)

fields = (['Entity', 'Count']) pt = PrettyTable(field_names=fields) field_names=fields pt.align ="l"

for (entity, freq) in entities_freqs: if freq > FREQ_THRESHOLD: pt.add_row([entity, freq])

print pt.get_string()