praw-dev / praw

PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

Home Page:http://praw.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: 'Redditor' object has no attribute 'icon_img'

pvs1209pvs opened this issue · comments

Describe the Bug

I get an AttributeError while trying to use .icon_img. It had been working fine around a month ago.

Desired Result

I expected to get the URL of the user's profile picture.

Relevant Logs

AttributeError: 'Redditor' object has no attribute 'icon_img'

Code to reproduce the bug

reddit = praw.Reddit(client_id, client_secret, user_agent)
url = reddit.redditor(username).icon_img

My code example does not include the Reddit() initialization to prevent credential leakage.

Yes

This code has previously worked as intended.

Yes

Operating System/Environment

Ubuntu 22.04.1 LTS

Python Version

Python 3.10

PRAW Version

7.6.1

Prawcore Version

2.3.0

Anything else?

No response

This is a side effect of Reddit's api returning inconsistent fields depending on which endpoint you fetched the object from. This is the reason for the paragraph/note before every attributes table saying the table is typical attributes and are subject to change without warning

Unfortunately this isn't a bug with PRAW that we are able to change.

What does " depending on which endpoint you fetched the object from" mean?

And is there any immediate fix?

What I mean by that is for example, in comments, some attributes are returned when you get the comment from a submission vs initializing them directly (which uses a different endpoint when you try and access the attribute).

And is there any immediate fix?

There is not. It is the nature of working with Reddit's API.

I just wanted to clarify, this wasn't a bug but a blunder on my part. The reason I was getting this error was becasuse that reddit user's account had been deactived. icon_img works just fine with active users.