PRAW: Python Reddit API Wrapper not working

Flare Cat picture Flare Cat · Oct 27, 2016 · Viewed 7.1k times · Source

I'm trying to make a Reddit bot, except I cannot even use the following simple example, nor the examples PRAW has in their docs.

The following code

import praw
r = praw.Reddit(user_agent="some useragent text")
r.login()

returns the following error

Traceback (most recent call last):
  File "savageAxeBot.py", line 3, in <module>
    r = praw.Reddit(user_agent="some useragent text")
  File "/Library/Python/2.7/site-packages/praw-4.0.0b21-py2.7.egg/praw/reddit.py", line 101, in __init__
    raise ClientException(required_message.format(attribute))
praw.exceptions.ClientException: Required configuration setting 'client_id' missing. 
This setting can be provided in a praw.ini file, as a keyword argument to the `Reddit` class constructor, or as an environment variable.

UPDATE: I've gotten both my client ID and secret. I managed to get the above code (exactly as shown) to work on Fedora 24, not could not get it to work on either Raspbian or Mac OS X.

PRAW seems easier to use from python than the Reddit API, so I would prefer to stick with it. Also, it appears that login() is depreciated, so how can I use OAuth2 (or whatever it is called)?

Note: I installed PRAW using easy_install praw, since pip install praw wasn't working. I tried using pip on both Mac OS X 10.12 and Raspbian, and neither worked. Any ideas?

Answer

Basic picture Basic · Oct 29, 2016

[Promoted/expanded from a comment]

As pointed out by @bboe, the PRAW docs can be located here ¹.

Specifically, you want the Getting Started ¹ page which walks you through instantiating a Reddit object in read-only or read/write mode.

¹ PRAW 4 documentation is no longer available onlne, so I've updated the links to track the latest version.