0
votes

I've tried everything and am at my wits end. I keep getting an error that reads "AttributeError: 'Reddit' object has no attribute 'subreddit'" I had praw 5.2 installed, then I uninstalled and manually installed praw 4.4 and both times it keeps telling me "Version 2.1.18 of praw is outdated. Version 5.2.0 was released Tuesday October 24, 2017." and when I edit the below:

reddit = praw.Reddit(client_id='8888',
                 client_secret='8888',
                 user_agent='8888_API:v1')

subreddit= r.subreddit('learnpython')

to

reddit = praw.Reddit(client_id='8888',
                 client_secret='8888',
                 user_agent='8888_API:v1')

    subreddit= r.get_subreddit('learnpython')

i.e. the old syntax, it runs fine. So it seems to think I have praw 2.1.18 even though I don't.

Full w/ traceback:

runfile('C:/Users/..../rAPI.py', wdir='C:/Users/....')
Version 2.1.18 of praw is outdated. Version 5.2.0 was released Tuesday October 24, 2017.
Traceback (most recent call last):

  File "<ipython-input-88-ab9c8af5b7e2>", line 1, in <module>
runfile('C:/Users/..../rAPI.py', wdir='C:/Users/....')

  File "C:\Users\....\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)

  File "C:\Users\....\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/..../rAPI.py", line 14, in <module>
subreddit= r.subreddit('learnpython')

AttributeError: 'Reddit' object has no attribute 'subreddit'
1
You use r.get_subreddit - what is r here? What happens if you try subreddit = reddit.get_subreddit('learnpython')? - wkl
Is there any specific reason you need to be running version 4.4? Try running pip install praw --upgrade. - Zeke Egherman

1 Answers

0
votes

First of all, you use a variable name r that you never defined. So it should first give a NameError: r is not defined.

Second, I would recommend using the latest version of praw. You can update using pip install --upgrade praw. Then you just use reddit.subreddit('learnpython') and everything should work fine.