Instapy: KeyError = 'username' and login issue

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

Expected Behavior

Iniciate quickstart.py after basic configuration of this file

Current Behavior

Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit msg = self.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 734, in format return fmt.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 469, in format s = self._fmt % record.__dict__ KeyError: 'username' Logged from file instapy.py, line 225 Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit msg = self.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 734, in format return fmt.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 469, in format s = self._fmt % record.__dict__ KeyError: 'username' Logged from file instapy.py, line 225 Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit msg = self.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 734, in format return fmt.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 469, in format s = self._fmt % record.__dict__ KeyError: 'username' Logged from file instapy.py, line 261 Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit msg = self.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 734, in format return fmt.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 469, in format s = self._fmt % record.__dict__ KeyError: 'username' Logged from file instapy.py, line 261 Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit msg = self.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 734, in format return fmt.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 469, in format s = self._fmt % record.__dict__ KeyError: 'username' Logged from file instapy.py, line 664 Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit msg = self.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 734, in format return fmt.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 469, in format s = self._fmt % record.__dict__ KeyError: 'username' Logged from file instapy.py, line 664 Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit msg = self.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 734, in format return fmt.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 469, in format s = self._fmt % record.__dict__ KeyError: 'username' Logged from file instapy.py, line 665 Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit msg = self.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 734, in format return fmt.format(record) File "/usr/lib/python2.7/logging/__init__.py", line 469, in format s = self._fmt % record.__dict__ KeyError: 'username' Logged from file instapy.py, line 665 ^CTraceback (most recent call last): File "quickstart.py", line 26, in <module> session.end() File "/home/allexus/InstaPy/instapy/instapy.py", line 1573, in end self.browser.delete_all_cookies() File "/home/allexus/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 655, in delete_all_cookies self.execute(Command.DELETE_ALL_COOKIES) File "/home/allexus/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute response = self.command_executor.execute(driver_command, params) File "/home/allexus/.local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 401, in execute return self._request(command_info[0], url, body=data) File "/home/allexus/.local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 432, in _request self._conn.request(method, parsed_url.path, body, headers) File "/usr/lib/python2.7/httplib.py", line 1042, in request self._send_request(method, url, body, headers) File "/usr/lib/python2.7/httplib.py", line 1082, in _send_request self.endheaders(body) File "/usr/lib/python2.7/httplib.py", line 1038, in endheaders self._send_output(message_body) File "/usr/lib/python2.7/httplib.py", line 882, in _send_output self.send(msg) File "/usr/lib/python2.7/httplib.py", line 844, in send self.connect() File "/usr/lib/python2.7/httplib.py", line 821, in connect self.timeout, self.source_address) File "/usr/lib/python2.7/socket.py", line 575, in create_connection raise err socket.error: [Errno 111] Connection refused

Possible Solution (optional)

I don't know if i have to configure another thing to test the functionality of the program. Is it necessary to configure the instapy.py before running?

InstaPy configuration

`from instapy import InstaPy

insta_username = 'alelima.psicologia'
insta_password = 'genesis12'

set headless_browser=True if you want to run InstaPy on a server

try:
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=False,
multi_logs=True)
session.login()

# settings
session.set_upper_follower_count(limit=500)
session.set_do_comment(True, percentage=10)
session.set_comments(['Adorei!', 'Isso ai, muito bom!!', 'Otima foto!'])
session.set_dont_include(['friend1', 'friend2', 'friend3'])
session.set_dont_like(['deus', 'pastor'])

# actions
session.like_by_tags(['motivacao', 'felicidade', 'sucesso'], amount=1)

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

wontfix

Most helpful comment

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

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

logger = logging.LoggerAdapter(logger, extra)

All 8 comments

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

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

logger = logging.LoggerAdapter(logger, extra)

@nafferro It worked at first, but now InstaPy doens't log in, even tough it says:
INFO [alelima.psicologia] Session started - 2018-01-31 18:33:22 INFO [alelima.psicologia] Logged in successfully!

When i see the browser it is not logged in and between the likes and comments it asks fot login informations. But the program doesn't log in again.

I miss the basic and clean implementation I made initially.

@converge , Can it have anything to do with the latest PR? I have the same error after pulling today..
Before that, I didn't pull for like two weeks.

--- Logging error ---
Traceback (most recent call last):
File "/usr/local/lib/python3.6/logging/__init__.py", line 992, in emit
msg = self.format(record)
File "/usr/local/lib/python3.6/logging/__init__.py", line 838, in format
return fmt.format(record)
File "/usr/local/lib/python3.6/logging/__init__.py", line 578, in format
s = self.formatMessage(record)
File "/usr/local/lib/python3.6/logging/__init__.py", line 547, in formatMessage
return self._style.format(record)
File "/usr/local/lib/python3.6/logging/__init__.py", line 391, in format
return self._fmt % record.__dict__
KeyError: 'username'

I was busy last month and I'm a bit outdated about the last updates, I can see that our logging system is a bit messy at the moment, but unfortunately I don't have the time to fix it :/

@converge, @nafferro has a solution mentioned above.

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