Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'JSONParser' object has no attribute 'model_factory' #538

Closed
atosatto opened this issue Jan 8, 2015 · 9 comments
Closed

'JSONParser' object has no attribute 'model_factory' #538

atosatto opened this issue Jan 8, 2015 · 9 comments
Assignees
Labels
Bug This is regarding a bug with the library
Milestone

Comments

@atosatto
Copy link

atosatto commented Jan 8, 2015

Running the following snippet of code using tweepy 3.1.0

# Autenticating
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

# API Access
api = tweepy.API(auth, parser=JSONParser(), wait_on_rate_limit=True)

# Dumping the "home" timeline
statuses = []
for s in tweepy.Cursor(api.user_timeline, id=PROFILE_HANDLE).items(10):
    print "We have currently fetched %d tweets" % len(statuses)
    statuses.append(s)

# Writing the output to a file
with open("output.json", "w") as outfile:
    json.dump(statuses, outfile, indent=1)

I get this error


Traceback (most recent call last):
  File "dumptwitterstream.py", line 32, in <module>
    for s in tweepy.Cursor(api.user_timeline, id=PROFILE_HANDLE).items(10):
  File "/usr/local/lib/python2.7/site-packages/tweepy/cursor.py", line 197, in next
    self.current_page = self.page_iterator.next()
  File "/usr/local/lib/python2.7/site-packages/tweepy/cursor.py", line 117, in next
    model = ModelParser().parse(self.method(create=True), data)
  File "/usr/local/lib/python2.7/site-packages/tweepy/parsers.py", line 95, in parse
    result = model.parse_list(method.api, json)
  File "/usr/local/lib/python2.7/site-packages/tweepy/models.py", line 65, in parse_list
    results.append(cls.parse(api, obj))
  File "/usr/local/lib/python2.7/site-packages/tweepy/models.py", line 81, in parse
    user_model = getattr(api.parser.model_factory, 'user') if api else User
AttributeError: 'JSONParser' object has no attribute 'model_factory'

The same code is fully working with tweepy 2.3.0.

@jschnurr
Copy link
Contributor

Same problem in 3.3.0.

@davidsemakula
Copy link

Same issue in 3.3.0

@hilbert- @jschnurr - Currently using this as a work around ... adds a little computation overhead and doesn't include metadata

statuses = []
data = tweepy.Cursor(api.search, **params).items(max)
for status in data:
    statuses.append(status._json)

@josh-byster
Copy link

Still having this issue in 3.5

@oussjarrousse
Copy link

oussjarrousse commented Aug 29, 2016

I am having this problem as well... in 3.5

@Horatio-Blackwood
Copy link

Same issue here when using json.loads in 3.5

@tech4242
Copy link

Stuck on this as well & can't revert to 2.3.0 as @davidsemakula suggested (currently using 3.5)

@Aaron1011 Aaron1011 self-assigned this Jul 25, 2017
@Harmon758 Harmon758 added the Bug This is regarding a bug with the library label May 1, 2019
@jski
Copy link

jski commented Feb 10, 2020

+1 to this issue for me as well.

@AlmuHS
Copy link

AlmuHS commented Jan 28, 2021

Same issue for me

@Harmon758
Copy link
Member

This should be resolved with 41e7afa in v4.0.0.

@Harmon758 Harmon758 added this to the 4.0 milestone Sep 28, 2021
Harmon758 added a commit to Harmon758/tweepy that referenced this issue Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is regarding a bug with the library
Projects
None yet
Development

No branches or pull requests