Heroku实例生成缺少某些属性

时间:2015-04-29 06:28:37

标签: python heroku

Python新手在这里!我在Heroku上部署脚本时遇到问题 - 它在本地工作正常,但是在Heroku上它会给我这个日志:

2015-04-28T09:48:43.362570+00:00 heroku[web.1]: State changed from crashed to starting
2015-04-28T09:48:47.047556+00:00 heroku[web.1]: Starting process with command `python reddit_bot2.py`
2015-04-28T09:48:49.458189+00:00 app[web.1]: :0: UserWarning: The keyword `bot` in your user_agent may be problematic.
2015-04-28T09:48:50.075734+00:00 app[web.1]: Logging in to Reddit...
2015-04-28T09:48:58.757114+00:00 app[web.1]: Accessing Subreddit...
2015-04-28T09:48:58.757095+00:00 app[web.1]: Logging into Goodreads API...
2015-04-28T09:49:03.040120+00:00 app[web.1]: Grabbing Submission 1
2015-04-28T09:49:05.056468+00:00 app[web.1]: Grabbing Comment 1
2015-04-28T09:49:05.056661+00:00 app[web.1]: Querying: disappearing spoon
2015-04-28T09:49:05.056790+00:00 app[web.1]:   File "reddit_bot2.py", line 119, in <module>
2015-04-28T09:49:05.056785+00:00 app[web.1]: Traceback (most recent call last):
2015-04-28T09:49:05.056885+00:00 app[web.1]:     main()
2015-04-28T09:49:05.056956+00:00 app[web.1]:   File "reddit_bot2.py", line 76, in main
2015-04-28T09:49:05.057002+00:00 app[web.1]:     rating, desc, link, authors = query_goodreads(comment_text)
2015-04-28T09:49:05.057035+00:00 app[web.1]:   File "reddit_bot2.py", line 93, in query_goodreads
2015-04-28T09:49:05.057071+00:00 app[web.1]:     query = gc.search_books(q, page= 1, search_field= 'all')
2015-04-28T09:49:05.057111+00:00 app[web.1]: AttributeError: GoodreadsClient instance has no attribute 'search_books'
2015-04-28T09:49:06.022454+00:00 heroku[web.1]: State changed from starting to crashed
2015-04-28T09:49:06.005309+00:00 heroku[web.1]: Process exited with status 1

主要错误是AttributeError。

搜索周围,其他人在Django上遇到这个错误,但解决方案似乎只适用于Django,我的脚本没有使用它 - 它确实使用Python API封装器来实现Goodreads(找到here )。 我稍微修改了一下代码,试图列出实例的属性。

print(dir(gc))

gc是GoodreadsClient实例,它打印了这个属性列表

[&#39; doc &#39;,&#39; init &#39;,&#39; 模块 &#39;,&#39; auth_user&#39;,&#39; authenticate&#39;,&#39; author&#39;,&#39; base_url&#39;,&#39; book&#39;, &#39; book_review_stats&#39;,&#39; client_key&#39;,&#39; client_secret&#39;,&#39; find_author&#39;,&#39; find_groups&#39;,&#39; group& #39;,&#39; list_comments&#39;,&#39; list_events&#39;,&#39; owned_book&#39;,&#39; query_dict&#39;,&#39; recent_reviews&#39;,& #39; request&#39;,&#39; request_oauth&#39;,&#39; review&#39;,&#39; search_books&#39;,&#39; user&#39;]

与API包装器的文档一致。但是一旦部署,就打印

[&#39; doc &#39;,&#39; init &#39;,&#39; 模块 &#39;,&#39; auth_user&#39;,&#39; authenticate&#39;,&#39; author&#39;,&#39; base_url&#39;,&#39; book&#39;, &#39; book_review_stats&#39;,&#39; client_key&#39;,&#39; client_secret&#39;,&#39; find_groups&#39;,&#39; group&#39;,&#39; list_comments& #39;,&#39; list_events&#39;,&#39; owned_book&#39;,&#39; query_dict&#39;,&#39; recent_reviews&#39;,&#39; request&#39;,& #39; request_oauth&#39;,&#39; review&#39;,&#39; user&#39;]

缺少&#39; find_author&#39;和&#39; search_books&#39;属性(search_books是在heroku上给出错误一次的属性)。 导致这些属性丢失的原因是什么?有解决方法吗?

我的script,如果有帮助的话。

0 个答案:

没有答案