我試圖寫一個redditbot;我決定從一個簡單的開始,以確保我正確地做事情,並且我得到了一個RequestException。PRAW提高RequestException當我嘗試運行簡單的機器人
我的代碼(bot.py):
import praw
for s in praw.Reddit('bot1').subreddit("learnpython").hot(limit=5):
print s.title
我praw.ini文件:
# The URL prefix for OAuth-related requests.
oauth_url=https://oauth.reddit.com
# The URL prefix for regular requests.
reddit_url=https://www.reddit.com
# The URL prefix for short URLs.
short_url=https://redd.it
[bot1]
client_id=HIDDEN
client_secret=HIDDEN
password=HIDDEN
username=HIDDEN
user_agent=ILovePythonBot0.1
(其中隱藏代替實際的ID,祕密,密碼和用戶名)
我的回溯:
Traceback (most recent call last):
File "bot.py", line 3, in <module>
for s in praw.Reddit('bot1').subreddit("learnpython").hot(limit=5):
File "/usr/local/lib/python2.7/dist-packages/praw/models/listing/generator.py", line 79, in next
return self.__next__()
File "/usr/local/lib/python2.7/dist-packages/praw/models/listing/generator.py", line 52, in __next__
self._next_batch()
File "/usr/local/lib/python2.7/dist-packages/praw/models/listing/generator.py", line 62, in _next_batch
self._listing = self._reddit.get(self.url, params=self.params)
File "/usr/local/lib/python2.7/dist-packages/praw/reddit.py", line 322, in get
data = self.request('GET', path, params=params)
File "/usr/local/lib/python2.7/dist-packages/praw/reddit.py", line 406, in request
params=params)
File "/usr/local/lib/python2.7/dist-packages/prawcore/sessions.py", line 131, in request
params=params, url=url)
File "/usr/local/lib/python2.7/dist-packages/prawcore/sessions.py", line 70, in _request_with_retries
params=params)
File "/usr/local/lib/python2.7/dist-packages/prawcore/rate_limit.py", line 28, in call
response = request_function(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/prawcore/requestor.py", line 48, in request
raise RequestException(exc, args, kwargs)
prawcore.exceptions.RequestException: error with request request() got an unexpected keyword argument 'json'
任何幫助,將不勝感激。 PS,我在Ubuntu 14.04上使用Python 2.7。請向我諮詢您可能需要的任何其他信息。
這很奇怪。你有什麼版本的prawcore,prawcore和請求:將PACKAGE替換爲每個版本的名稱以從PACKAGE import __version__獲取版本:'python -c'; print(__ version __)''我的直覺是你有一箇舊版本的請求不支持這個參數。但是,如果使用pip來安裝praw,那應該是不可能的。你是如何安裝praw的? – bboe
@bboe我正在使用: praw 4.1.0 prawcore 0.5.0 請求2.2.1 我用pip安裝了praw。 – CoffeeTableEspresso
這真的很有趣,因爲prawcore依賴於'requests> = 2.9.1',因此pip不會成功安裝該版本的PRAW。嘗試'pip install -U praw'並查看它是否改變了請求版本。 – bboe