Instapy: Self-logger still seems to be returning error

Created on 31 Jan 2018  路  7Comments  路  Source: timgrossmann/InstaPy

Expected Behavior

Current Behavior

Error seems to occur while executing: session.interact_user_followers(['punkhippie'], amount=50, randomize=True) function

Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 992, in emit
msg = self.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 838, in format
return fmt.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 578, in format
s = self.formatMessage(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 547, in formatMessage
return self._style.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 391, in format
return self._fmt % record.__dict__
KeyError: 'username'
Call stack:
File "quickstart.py", line 89, in
session.follow_user_followers(['punkhippie'], amount=40, randomize=True, sleep_delay=800)
File "/Users/User/Downloads/InstaPy-master/instapy/instapy.py", line 1241, in follow_user_followers
self.follow_times)
File "/Users/User/Downloads/InstaPy-master/instapy/unfollow_util.py", line 741, in follow_given_user_followers
callbacks=[])
File "/Users/User/Downloads/InstaPy-master/instapy/unfollow_util.py", line 558, in follow_through_dialog
logger.error("follow loop error {}".format(str(e)))
Message: 'follow loop error Sample larger than population or is negative'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 992, in emit
msg = self.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 838, in format
return fmt.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 578, in format
s = self.formatMessage(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 547, in formatMessage
return self._style.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 391, in format
return self._fmt % record.__dict__
KeyError: 'username'
Call stack:
File "quickstart.py", line 89, in
session.follow_user_followers(['punkhippie'], amount=40, randomize=True, sleep_delay=800)
File "/Users/User/Downloads/InstaPy-master/instapy/instapy.py", line 1254, in follow_user_followers
"--> Total people followed : {} ".format(len(userFollowed)))
Message: '--> Total people followed : 0 '

Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 992, in emit
msg = self.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 838, in format
return fmt.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 578, in format
s = self.formatMessage(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 547, in formatMessage
return self._style.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 391, in format
return self._fmt % record.__dict__
KeyError: 'username'
Call stack:
File "quickstart.py", line 100, in
session.end()
File "/Users/User/Downloads/InstaPy-master/instapy/instapy.py", line 1580, in end
datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
Message: 'Session ended - 2018-01-31 23:14:59'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 992, in emit
msg = self.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 838, in format
return fmt.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 578, in format
s = self.formatMessage(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 547, in formatMessage
return self._style.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 391, in format
return self._fmt % record.__dict__
KeyError: 'username'
Call stack:
File "quickstart.py", line 100, in
session.end()
File "/Users/User/Downloads/InstaPy-master/instapy/instapy.py", line 1581, in end
self.logger.info('-' * 20 + '\n\n')
Message: '--------------------\n\n'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 992, in emit
msg = self.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 838, in format
return fmt.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 578, in format
s = self.formatMessage(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 547, in formatMessage
return self._style.format(record)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 391, in format
return self._fmt % record.__dict__
KeyError: 'username'
Call stack:
File "quickstart.py", line 100, in
session.end()
File "/Users/User/Downloads/InstaPy-master/instapy/instapy.py", line 1581, in end
self.logger.info('-' * 20 + '\n\n')
Message: '--------------------\n\n'
Arguments: ()

Possible Solution (optional)

InstaPy configuration

wontfix

All 7 comments

I have the same issue on my computer and my server.

in line 165 of instapy.py
replace self.logger with logger

self.logger = logging.LoggerAdapter(logger, extra)

should be

logger = logging.LoggerAdapter(logger, extra)

of get_instapy_logger() method ...
@ramprasadc @clevebounce
details

The solution by @uluQulu Works for me!

@luigifaticoso this part work for me too.

But it still did not resolve the errors that I belief was caused by the last 3 commits...

the function session.like_by_tags has a problem which it does not have before.. If I specify 6 tags each 200 likes for instances, it would only do 200 likes for the first tag.. the rest of the tags maybe each 12. that is what is happening to me

@uluQulu, thank you for your help. Unfortunately, instapy.py does not have this at line 165, but instead has it at line 183. In addition, it is not self.logger for me, it has already been changed to simply
logger = logging.LoggerAdapter(logger, extra)
I only use follow_user_followers, and it works fine if the terminal is active/in the foreground on the Desktop. However, if I do anything else on my computer (and terminal is not in the front), it will give me the following error:

WARNING [date time] [my_username] users_followers_to_follow -> Less users to follow than requested.
ERROR [date time] [my_username] follow loop error Sample larger than population or is negative

and then it will move on to the next user on my list. If I move it back to the foreground, it will continue normally, but if not, it will continue to produce these errors with everyone else on the list. I'm confused as to how this works (I apologize, I'm not very proficient with Python).

welcome @ekumar96,
this thread is solving the old issue _happened after_ logger mechanish changed and is not affecting anything else than the console output and the fix above _was added_ to main files some time ago so it is there in your files normally
your issue is something different, i have got hints, let's investigate it further in #1231

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this problem still occurs, please open a new issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

converge picture converge  路  3Comments

seuraltimez picture seuraltimez  路  3Comments

ediooo picture ediooo  路  3Comments

ingorichter picture ingorichter  路  3Comments

v77v picture v77v  路  3Comments