Instapy: NameError: name 'session' is not defined

Created on 7 Apr 2018  路  7Comments  路  Source: timgrossmann/InstaPy

Expected Behavior

Run the bot

Current Behavior

C:\Users\xxx\Documents\InstaPy>follow_xxx.py
Traceback (most recent call last):
  File "C:\Users\xxx\Documents\InstaPy\follow_xxx.py", line 15, in <module>
    multi_logs=True)
  File "C:\Users\xxx\Documents\InstaPy\instapy\instapy.py", line 116, in __init__
    self.follow_restrict = load_follow_restriction(self.logfolder)
  File "C:\Users\xxx\Documents\InstaPy\instapy\unfollow_util.py", line 893, in load_follow_restriction
    return json.load(followResFile)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 8194 (char 8193)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xxx\Documents\InstaPy\follow_xxx.py", line 37, in <module>
    session.end()
NameError: name 'session' is not defined

This only happens on two accounts, the rest are fine. Are those accounts banned?

All 7 comments

The error JSONDecodeError: Expecting property name enclosed in double quotes: suggests me that you might have some double-quote typos in your JSON file containing the settings. Try to double check that!

That's not the case, I'm afraid.
When I launch a config with my credidentals (on a file that works with a different account), I get the same error.

Did you manually open the file followRestriction.json??? There might be a missing char over there. I'd suggest to manually copy the content and validate it with something like https://jsonlint.com/

edit:

finally:
    # end the bot session
    session.end()

not:

finally:
    # end the bot session
session.end()

"Did you manually open the file followRestriction.json???" Yes, I did. I downloaded a new one (InstaPylogsfollowRestriction.json) and my problem was solved. Thanks MrBeardedGuy.

I was still logged on to Instagram on my browser and every time I tried to comment something or delete a comment on one of my posts it gave me an 405 error.
I relogged my browser and everything worked fine. I did the same thing with the script, I deleted all my userfiles for those two accounts that weren't working and re-logged them and now everything works fine again.

@atemerino Always make sure that the chromedriver is up to date, just had this problem, it disappeared once I updated to the latest one

Please reopen if not fixed

Was this page helpful?
0 / 5 - 0 ratings