Skip to content

ValueError: Unrecognised argument(s): encoding #47

Closed
@edoardottt

Description

@edoardottt

If twitterbot2 gives you this error:

$> python3 twitterbot2.py -h
Traceback (most recent call last):
  File "http://twitterbot2.py", line 668, in <module>
    main()
  File "http://twitterbot2.py", line 581, in main
    format=http://globals.bot_user + ": %(levelname)s:%(asctime)s | %(message)s",
  File "/Library/Frameworks/Python.framework/Versions/3.x/lib/python3.x/logging/__init__.py", line 1919, in basicConfig
    raise ValueError('Unrecognised argument(s): %s' % keys)
ValueError: Unrecognised argument(s): encoding

The problem is at this line and you have two solutions:

  • Upgrade python to version 3.9
  • OR
  • Edit your twitterbot2.py file deleting the basicConfig method and use instead:
root_logger= logging.getLogger(__name__)
root_logger.setLevel(logging.INFO)
handler = logging.FileHandler('twitterbot2.log', 'a', 'utf-8')
handler.setFormatter(logging.Formatter(globals.bot_user + ": %(levelname)s:%(asctime)s | %(message)s"))
root_logger.addHandler(handler)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions