sefakilic/goodreads

attribute error in deployment

Closed this issue · 4 comments

Hi! I'm sorry to bother you again. I get the error message on the logs on Heroku:

2015-04-29T07:57:14.996321+00:00 app[web.1]: AttributeError: GoodreadsClient instance has no attribute 'search_books'

Yet, the GoodreadsClient instance has this attribute locally (I am able to execute my script locally).

Doing some digging, I found that when deployed, GoodreadsClient instance does not have the 'search_books' and 'find_author' instances (though the rest of the attributes work fine). I thought it may be a version error on the deployed copy on Heroku as these functions were only added recently, but both my local copy and the deployed copy of the module are up-to-date (based on the requirements.txt file I included in deployment).

Hi, thanks for using the library and letting me know about the bugs/issues.

Do you mean you are getting the same error even after you updated the library to the latest version?

It seems working fine for me. Tests also run with no issue.

Yes, I believe so. Perhaps something is wrong with the way I installed it?

Here's the contents of a testing script I ran (everything I pushed to the Heroku repo, minus the config file): https://github.com/FatNarwhal/goodreads_testing

In virtualenv, after installing the API wrapper and dependencies, I created a requirements.txt (I generated it by pip freeze > requirements.txt). Pushed to heroku, no error messages. I run it, but the logs give me:

Starting process with command 'python test.py'
State changed from starting to up
Traceback (most recent call last):
File "test.py", line 12, in
query = gc.search_books('the sound and the fury', page= 1, search_field= 'all')
AttributeError: GoodreadsClient instance has no attribute 'search_books'
State changed from up to crashed
Process exited with status 1

But in my local environment it runs smoothly, printing 10975 as expected. :-)

My hunch is that heroku is somehow installing the wrong version, but it doesn't give me any error messages and even confirmed during installation that it downloaded goodreads 0.2.3

Edit: Also, I don't know if this is relevant, but I'm using default Python 2.7.6 locally. Heroku servers (at least from what I've read) seems to run Python 2.7.9 by default.
Edit2: I found out that the two attributes weren't on the deployed copies when I tried print(dir(gc)). Locally, it gave me all the GoodreadsClient attributes consistent with your documentation (['__doc__', '__init__',... 'user']). On deployment, it returned the same list, sans search_books and find_author. That's the only basis of my hunch that it's running the wrong version though. Is there a way to verify on the script which version I'm using?

Hi again! I think I was able to reproduce my issue locally!

Installing goodreads via requirements.txt

#requirements.txt`
xmltodict
requests
rauth
goodreads

and then running in the interpreter

$ pip install -r requirements.txt
...
Successfully installed goodreads-0.2.3 nose-1.3.6 rauth-0.7.1 requests-2.6.2 xmltodict-0.9.2
$ python
>>>from goodreads.client import GoodreadsClient
>>>dir(GoodreadsClient)
['__doc__', '__init__', '__module__', 'auth_user', 'authenticate', 'author', 'base_url',
'book', 'book_review_stats', 'find_groups', 'group', 'list_comments', 'list_events',
'owned_book', 'query_dict', 'recent_reviews', 'request', 'request_oauth', 'review', 'user']
>>>

Which does not contain the newly added methods.

My bad. The version on PyPI didn't have these attributes. I uploaded the latest version. Download it again, please. Thanks!