question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows 10 - RuntimeError: Event loop is closed and UnicodeEncodeError: 'charmap' codec can't encode character

See original GitHub issue

Not a bug, but perhaps it should be mentioned that databay will not work with Windows 10 due to a bug or the way asyncio chooses the default event loop mechanism, which throws an error, instead of just a warning.

So if running asyncio-dependent code on Windows machine, you will get an error similar below:

Traceback (most recent call last):
  File "C:\Programs\Python38\lib\asyncio\proactor_events.py", line 95, in __del__
    self.close()
  File "C:\Programs\Python38\lib\asyncio\proactor_events.py", line 86, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Programs\Python38\lib\asyncio\base_events.py", line 683, in call_soon
    self._check_closed()
  File "C:\Programs\Python38\lib\asyncio\base_events.py", line 475, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Per this SO question, possible workaround is to use asyncio loop’s run_until_complete() instead of just run()


(Update 1 by Voy - added more info)

To Reproduce Example code (blockchain example):

import datetime

from databay.inlets import HttpInlet
from databay.outlets import PrintOutlet
from databay import Link
from databay.planners import APSPlanner

stock_inlet = HttpInlet('https://blockchain.info/ticker')

print_outlet = PrintOutlet(True, True)

link = Link(stock_inlet, print_outlet, interval=datetime.timedelta(seconds=1))

planner = APSPlanner(link)

planner.start()

Environment Databay version: 0.1.2 Python version: 3.8.2 OS: Ubuntu 20.04 and Windows 10


(Update 2 by Voy - explaining the true issue)

The RuntimeError: Event loop is closed is only half of the problem here, and in fact is not the cause for the code to stop working, but a side effect happening when program terminates and can be fixed easily. The code wouldn’t execute due to UnicodeEncodeError, which we figure out later down the line.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:22 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
pybokehcommented, Aug 24, 2020

@Voyz Well good news! Finally, got the blockchain_demo.py working.

Added:

import sys
import asyncio

if sys.version_info[0] == 3 and sys.version_info[1] >= 8 and sys.platform.startswith('win'):
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

to the top of my local copy of config.py

and then at the terminal, executed:

chcp 65001
set PYTHONIOENCODING=utf-8

Then executed the blockchain_demo.py:

D:\Python38\envs\streaming_dev
(streaming_dev) λ python -m pdb blockchain_demo.py
> d:\python38\envs\streaming_dev\blockchain_demo.py(2)<module>()
-> import datetime
(Pdb) c
> d:\python38\envs\streaming_dev\lib\site-packages\databay\planners\aps_planner.py(134)_start_planner()
-> self._scheduler.start()
(Pdb) c
{'USD': {'15m': 11616.04, 'last': 11616.04, 'buy': 11616.04, 'sell': 11616.04, 'symbol': '$'}, 'AUD': {'15m': 16205.74, 'last': 16205.74, 'buy': 16205.74, 'sell': 16205.74, 'symbol': '$'}, 'BRL': {'15m': 65301.28, 'last': 65301.28, 'buy': 65301.28, 'sell': 65301.28, 'symbol': 'R$'}, 'CAD': {'15m': 15303.79, 'last': 15303.79, 'buy': 15303.79, 'sell': 15303.79, 'symbol': '$'}, 'CHF': {'15m': 10588.28, 'last': 10588.28, 'buy': 10588.28, 'sell': 10588.28, 'symbol': 'CHF'}, 'CLP': {'15m': 9212683.9, 'last': 9212683.9, 'buy': 9212683.9, 'sell': 9212683.9, 'symbol': '$'}, 'CNY': {'15m': 80377.21, 'last': 80377.21, 'buy': 80377.21, 'sell': 80377.21, 'symbol': '¥'}, 'DKK': {'15m': 73255.41, 'last': 73255.41, 'buy': 73255.41, 'sell': 73255.41, 'symbol': 'kr'}, 'EUR': {'15m': 9864.6, 'last': 9864.6, 'buy': 9864.6, 'sell': 9864.6, 'symbol': '€'}, 'GBP': {'15m': 8866.84, 'last': 8866.84, 'buy': 8866.84, 'sell': 8866.84, 'symbol': '£'}, 'HKD': {'15m': 90027.47, 'last': 90027.47, 'buy': 90027.47, 'sell': 90027.47, 'symbol': '$'}, 'INR': {'15m': 870356.18, 'last': 870356.18, 'buy': 870356.18, 'sell': 870356.18, 'symbol': '₹'}, 'ISK': {'15m': 1601038.9, 'last': 1601038.9, 'buy': 1601038.9, 'sell': 1601038.9, 'symbol': 'kr'}, 'JPY': {'15m': 1231929.44, 'last': 1231929.44, 'buy': 1231929.44, 'sell': 1231929.44, 'symbol': '¥'}, 'KRW': {'15m': 13843360.88, 'last': 13843360.88, 'buy': 13843360.88, 'sell': 13843360.88, 'symbol': '₩'}, 'NZD': {'15m': 17753.7, 'last': 17753.7, 'buy': 17753.7, 'sell': 17753.7, 'symbol': '$'}, 'PLN': {'15m': 43410.94, 'last': 43410.94, 'buy': 43410.94, 'sell': 43410.94, 'symbol': 'zł'}, 'RUB': {'15m': 868955.96, 'last': 868955.96, 'buy': 868955.96, 'sell': 868955.96, 'symbol': 'RUB'}, 'SEK': {'15m': 102017.68, 'last': 102017.68, 'buy': 102017.68, 'sell': 102017.68, 'symbol': 'kr'}, 'SGD': {'15m': 15933.58, 'last': 15933.58, 'buy': 15933.58, 'sell': 15933.58, 'symbol': '$'}, 'THB': {'15m': 366042.0, 'last': 366042.0, 'buy': 366042.0, 'sell': 366042.0, 'symbol': '฿'}, 'TRY': {'15m': 85021.27, 'last': 85021.27, 'buy': 85021.27, 'sell': 85021.27, 'symbol': '₺'}, 'TWD': {'15m': 341550.96, 'last': 341550.96, 'buy': 341550.96, 'sell': 341550.96, 'symbol': 'NT$'}}
{'USD': {'15m': 11616.04, 'last': 11616.04, 'buy': 11616.04, 'sell': 11616.04, 'symbol': '$'}, 'AUD': {'15m': 16205.74, 'last': 16205.74, 'buy': 16205.74, 'sell': 16205.74, 'symbol': '$'}, 'BRL': {'15m': 65301.28, 'last': 65301.28, 'buy': 65301.28, 'sell': 65301.28, 'symbol': 'R$'}, 'CAD': {'15m': 15303.79, 'last': 15303.79, 'buy': 15303.79, 'sell': 15303.79, 'symbol': '$'}, 'CHF': {'15m': 10588.28, 'last': 10588.28, 'buy': 10588.28, 'sell': 10588.28, 'symbol': 'CHF'}, 'CLP': {'15m': 9212683.9, 'last': 9212683.9, 'buy': 9212683.9, 'sell': 9212683.9, 'symbol': '$'}, 'CNY': {'15m': 80377.21, 'last': 80377.21, 'buy': 80377.21, 'sell': 80377.21, 'symbol': '¥'}, 'DKK': {'15m': 73255.41, 'last': 73255.41, 'buy': 73255.41, 'sell': 73255.41, 'symbol': 'kr'}, 'EUR': {'15m': 9864.6, 'last': 9864.6, 'buy': 9864.6, 'sell': 9864.6, 'symbol': '€'}, 'GBP': {'15m': 8866.84, 'last': 8866.84, 'buy': 8866.84, 'sell': 8866.84, 'symbol': '£'}, 'HKD': {'15m': 90027.47, 'last': 90027.47, 'buy': 90027.47, 'sell': 90027.47, 'symbol': '$'}, 'INR': {'15m': 870356.18, 'last': 870356.18, 'buy': 870356.18, 'sell': 870356.18, 'symbol': '₹'}, 'ISK': {'15m': 1601038.9, 'last': 1601038.9, 'buy': 1601038.9, 'sell': 1601038.9, 'symbol': 'kr'}, 'JPY': {'15m': 1231929.44, 'last': 1231929.44, 'buy': 1231929.44, 'sell': 1231929.44, 'symbol': '¥'}, 'KRW': {'15m': 13843360.88, 'last': 13843360.88, 'buy': 13843360.88, 'sell': 13843360.88, 'symbol': '₩'}, 'NZD': {'15m': 17753.7, 'last': 17753.7, 'buy': 17753.7, 'sell': 17753.7, 'symbol': '$'}, 'PLN': {'15m': 43410.94, 'last': 43410.94, 'buy': 43410.94, 'sell': 43410.94, 'symbol': 'zł'}, 'RUB': {'15m': 868955.96, 'last': 868955.96, 'buy': 868955.96, 'sell': 868955.96, 'symbol': 'RUB'}, 'SEK': {'15m': 102017.68, 'last': 102017.68, 'buy': 102017.68, 'sell': 102017.68, 'symbol': 'kr'}, 'SGD': {'15m': 15933.58, 'last': 15933.58, 'buy': 15933.58, 'sell': 15933.58, 'symbol': '$'}, 'THB': {'15m': 366042.0, 'last': 366042.0, 'buy': 366042.0, 'sell': 366042.0, 'symbol': '฿'}, 'TRY': {'15m': 85021.27, 'last': 85021.27, 'buy': 85021.27, 'sell': 85021.27, 'symbol': '₺'}, 'TWD': {'15m': 341550.96, 'last': 341550.96, 'buy': 341550.96, 'sell': 341550.96, 'symbol': 'NT$'}}
{'USD': {'15m': 11616.04, 'last': 11616.04, 'buy': 11616.04, 'sell': 11616.04, 'symbol': '$'}, 'AUD': {'15m': 16205.74, 'last': 16205.74, 'buy': 16205.74, 'sell': 16205.74, 'symbol': '$'}, 'BRL': {'15m': 65301.28, 'last': 65301.28, 'buy': 65301.28, 'sell': 65301.28, 'symbol': 'R$'}, 'CAD': {'15m': 15303.79, 'last': 15303.79, 'buy': 15303.79, 'sell': 15303.79, 'symbol': '$'}, 'CHF': {'15m': 10588.28, 'last': 10588.28, 'buy': 10588.28, 'sell': 10588.28, 'symbol': 'CHF'}, 'CLP': {'15m': 9212683.9, 'last': 9212683.9, 'buy': 9212683.9, 'sell': 9212683.9, 'symbol': '$'}, 'CNY': {'15m': 80377.21, 'last': 80377.21, 'buy': 80377.21, 'sell': 80377.21, 'symbol': '¥'}, 'DKK': {'15m': 73255.41, 'last': 73255.41, 'buy': 73255.41, 'sell': 73255.41, 'symbol': 'kr'}, 'EUR': {'15m': 9864.6, 'last': 9864.6, 'buy': 9864.6, 'sell': 9864.6, 'symbol': '€'}, 'GBP': {'15m': 8866.84, 'last': 8866.84, 'buy': 8866.84, 'sell': 8866.84, 'symbol': '£'}, 'HKD': {'15m': 90027.47, 'last': 90027.47, 'buy': 90027.47, 'sell': 90027.47, 'symbol': '$'}, 'INR': {'15m': 870356.18, 'last': 870356.18, 'buy': 870356.18, 'sell': 870356.18, 'symbol': '₹'}, 'ISK': {'15m': 1601038.9, 'last': 1601038.9, 'buy': 1601038.9, 'sell': 1601038.9, 'symbol': 'kr'}, 'JPY': {'15m': 1231929.44, 'last': 1231929.44, 'buy': 1231929.44, 'sell': 1231929.44, 'symbol': '¥'}, 'KRW': {'15m': 13843360.88, 'last': 13843360.88, 'buy': 13843360.88, 'sell': 13843360.88, 'symbol': '₩'}, 'NZD': {'15m': 17753.7, 'last': 17753.7, 'buy': 17753.7, 'sell': 17753.7, 'symbol': '$'}, 'PLN': {'15m': 43410.94, 'last': 43410.94, 'buy': 43410.94, 'sell': 43410.94, 'symbol': 'zł'}, 'RUB': {'15m': 868955.96, 'last': 868955.96, 'buy': 868955.96, 'sell': 868955.96, 'symbol': 'RUB'}, 'SEK': {'15m': 102017.68, 'last': 102017.68, 'buy': 102017.68, 'sell': 102017.68, 'symbol': 'kr'}, 'SGD': {'15m': 15933.58, 'last': 15933.58, 'buy': 15933.58, 'sell': 15933.58, 'symbol': '$'}, 'THB': {'15m': 366042.0, 'last': 366042.0, 'buy': 366042.0, 'sell': 366042.0, 'symbol': '฿'}, 'TRY': {'15m': 85021.27, 'last': 85021.27, 'buy': 85021.27, 'sell': 85021.27, 'symbol': '₺'}, 'TWD': {'15m': 341550.96, 'last': 341550.96, 'buy': 341550.96, 'sell': 341550.96, 'symbol': 'NT$'}}
{'USD': {'15m': 11616.82, 'last': 11616.82, 'buy': 11616.82, 'sell': 11616.82, 'symbol': '$'}, 'AUD': {'15m': 16204.46, 'last': 16204.46, 'buy': 16204.46, 'sell': 16204.46, 'symbol': '$'}, 'BRL': {'15m': 65305.65, 'last': 65305.65, 'buy': 65305.65, 'sell': 65305.65, 'symbol': 'R$'}, 'CAD': {'15m': 15302.23, 'last': 15302.23, 'buy': 15302.23, 'sell': 15302.23, 'symbol': '$'}, 'CHF': {'15m': 10588.85, 'last': 10588.85, 'buy': 10588.85, 'sell': 10588.85, 'symbol': 'CHF'}, 'CLP': {'15m': 9213275.97, 'last': 9213275.97, 'buy': 9213275.97, 'sell': 9213275.97, 'symbol': '$'}, 'CNY': {'15m': 80382.58, 'last': 80382.58, 'buy': 80382.58, 'sell': 80382.58, 'symbol': '¥'}, 'DKK': {'15m': 73286.28, 'last': 73286.28, 'buy': 73286.28, 'sell': 73286.28, 'symbol': 'kr'}, 'EUR': {'15m': 9865.33, 'last': 9865.33, 'buy': 9865.33, 'sell': 9865.33, 'symbol': '€'}, 'GBP': {'15m': 8868.58, 'last': 8868.58, 'buy': 8868.58, 'sell': 8868.58, 'symbol': '£'}, 'HKD': {'15m': 90033.14, 'last': 90033.14, 'buy': 90033.14, 'sell': 90033.14, 'symbol': '$'}, 'INR': {'15m': 870414.34, 'last': 870414.34, 'buy': 870414.34, 'sell': 870414.34, 'symbol': '₹'}, 'ISK': {'15m': 1601145.91, 'last': 1601145.91, 'buy': 1601145.91, 'sell': 1601145.91, 'symbol': 'kr'}, 'JPY': {'15m': 1231925.29, 'last': 1231925.29, 'buy': 1231925.29, 'sell': 1231925.29, 'symbol': '¥'}, 'KRW': {'15m': 13844286.07, 'last': 13844286.07, 'buy': 13844286.07, 'sell': 13844286.07, 'symbol': '₩'}, 'NZD': {'15m': 17752.53, 'last': 17752.53, 'buy': 17752.53, 'sell': 17752.53, 'symbol': '$'}, 'PLN': {'15m': 43424.56, 'last': 43424.56, 'buy': 43424.56, 'sell': 43424.56, 'symbol': 'zł'}, 'RUB': {'15m': 869014.03, 'last': 869014.03, 'buy': 869014.03, 'sell': 869014.03, 'symbol': 'RUB'}, 'SEK': {'15m': 101821.42, 'last': 101821.42, 'buy': 101821.42, 'sell': 101821.42, 'symbol': 'kr'}, 'SGD': {'15m': 15935.16, 'last': 15935.16, 'buy': 15935.16, 'sell': 15935.16, 'symbol': '$'}, 'THB': {'15m': 366204.5, 'last': 366204.5, 'buy': 366204.5, 'sell': 366204.5, 'symbol': '฿'}, 'TRY': {'15m': 85170.95, 'last': 85170.95, 'buy': 85170.95, 'sell': 85170.95, 'symbol': '₺'}, 'TWD': {'15m': 341573.79, 'last': 341573.79, 'buy': 341573.79, 'sell': 341573.79, 'symbol': 'NT$'}}
{'USD': {'15m': 11616.04, 'last': 11616.04, 'buy': 11616.04, 'sell': 11616.04, 'symbol': '$'}, 'AUD': {'15m': 16205.74, 'last': 16205.74, 'buy': 16205.74, 'sell': 16205.74, 'symbol': '$'}, 'BRL': {'15m': 65301.28, 'last': 65301.28, 'buy': 65301.28, 'sell': 65301.28, 'symbol': 'R$'}, 'CAD': {'15m': 15303.79, 'last': 15303.79, 'buy': 15303.79, 'sell': 15303.79, 'symbol': '$'}, 'CHF': {'15m': 10588.28, 'last': 10588.28, 'buy': 10588.28, 'sell': 10588.28, 'symbol': 'CHF'}, 'CLP': {'15m': 9212683.9, 'last': 9212683.9, 'buy': 9212683.9, 'sell': 9212683.9, 'symbol': '$'}, 'CNY': {'15m': 80377.21, 'last': 80377.21, 'buy': 80377.21, 'sell': 80377.21, 'symbol': '¥'}, 'DKK': {'15m': 73255.41, 'last': 73255.41, 'buy': 73255.41, 'sell': 73255.41, 'symbol': 'kr'}, 'EUR': {'15m': 9864.6, 'last': 9864.6, 'buy': 9864.6, 'sell': 9864.6, 'symbol': '€'}, 'GBP': {'15m': 8866.84, 'last': 8866.84, 'buy': 8866.84, 'sell': 8866.84, 'symbol': '£'}, 'HKD': {'15m': 90027.47, 'last': 90027.47, 'buy': 90027.47, 'sell': 90027.47, 'symbol': '$'}, 'INR': {'15m': 870356.18, 'last': 870356.18, 'buy': 870356.18, 'sell': 870356.18, 'symbol': '₹'}, 'ISK': {'15m': 1601038.9, 'last': 1601038.9, 'buy': 1601038.9, 'sell': 1601038.9, 'symbol': 'kr'}, 'JPY': {'15m': 1231929.44, 'last': 1231929.44, 'buy': 1231929.44, 'sell': 1231929.44, 'symbol': '¥'}, 'KRW': {'15m': 13843360.88, 'last': 13843360.88, 'buy': 13843360.88, 'sell': 13843360.88, 'symbol': '₩'}, 'NZD': {'15m': 17753.7, 'last': 17753.7, 'buy': 17753.7, 'sell': 17753.7, 'symbol': '$'}, 'PLN': {'15m': 43410.94, 'last': 43410.94, 'buy': 43410.94, 'sell': 43410.94, 'symbol': 'zł'}, 'RUB': {'15m': 868955.96, 'last': 868955.96, 'buy': 868955.96, 'sell': 868955.96, 'symbol': 'RUB'}, 'SEK': {'15m': 102017.68, 'last': 102017.68, 'buy': 102017.68, 'sell': 102017.68, 'symbol': 'kr'}, 'SGD': {'15m': 15933.58, 'last': 15933.58, 'buy': 15933.58, 'sell': 15933.58, 'symbol': '$'}, 'THB': {'15m': 366042.0, 'last': 366042.0, 'buy': 366042.0, 'sell': 366042.0, 'symbol': '฿'}, 'TRY': {'15m': 85021.27, 'last': 85021.27, 'buy': 85021.27, 'sell': 85021.27, 'symbol': '₺'}, 'TWD': {'15m': 341550.96, 'last': 341550.96, 'buy': 341550.96, 'sell': 341550.96, 'symbol': 'NT$'}}
{'USD': {'15m': 11616.04, 'last': 11616.04, 'buy': 11616.04, 'sell': 11616.04, 'symbol': '$'}, 'AUD': {'15m': 16205.74, 'last': 16205.74, 'buy': 16205.74, 'sell': 16205.74, 'symbol': '$'}, 'BRL': {'15m': 65301.28, 'last': 65301.28, 'buy': 65301.28, 'sell': 65301.28, 'symbol': 'R$'}, 'CAD': {'15m': 15303.79, 'last': 15303.79, 'buy': 15303.79, 'sell': 15303.79, 'symbol': '$'}, 'CHF': {'15m': 10588.28, 'last': 10588.28, 'buy': 10588.28, 'sell': 10588.28, 'symbol': 'CHF'}, 'CLP': {'15m': 9212683.9, 'last': 9212683.9, 'buy': 9212683.9, 'sell': 9212683.9, 'symbol': '$'}, 'CNY': {'15m': 80377.21, 'last': 80377.21, 'buy': 80377.21, 'sell': 80377.21, 'symbol': '¥'}, 'DKK': {'15m': 73255.41, 'last': 73255.41, 'buy': 73255.41, 'sell': 73255.41, 'symbol': 'kr'}, 'EUR': {'15m': 9864.6, 'last': 9864.6, 'buy': 9864.6, 'sell': 9864.6, 'symbol': '€'}, 'GBP': {'15m': 8866.84, 'last': 8866.84, 'buy': 8866.84, 'sell': 8866.84, 'symbol': '£'}, 'HKD': {'15m': 90027.47, 'last': 90027.47, 'buy': 90027.47, 'sell': 90027.47, 'symbol': '$'}, 'INR': {'15m': 870356.18, 'last': 870356.18, 'buy': 870356.18, 'sell': 870356.18, 'symbol': '₹'}, 'ISK': {'15m': 1601038.9, 'last': 1601038.9, 'buy': 1601038.9, 'sell': 1601038.9, 'symbol': 'kr'}, 'JPY': {'15m': 1231929.44, 'last': 1231929.44, 'buy': 1231929.44, 'sell': 1231929.44, 'symbol': '¥'}, 'KRW': {'15m': 13843360.88, 'last': 13843360.88, 'buy': 13843360.88, 'sell': 13843360.88, 'symbol': '₩'}, 'NZD': {'15m': 17753.7, 'last': 17753.7, 'buy': 17753.7, 'sell': 17753.7, 'symbol': '$'}, 'PLN': {'15m': 43410.94, 'last': 43410.94, 'buy': 43410.94, 'sell': 43410.94, 'symbol': 'zł'}, 'RUB': {'15m': 868955.96, 'last': 868955.96, 'buy': 868955.96, 'sell': 868955.96, 'symbol': 'RUB'}, 'SEK': {'15m': 102017.68, 'last': 102017.68, 'buy': 102017.68, 'sell': 102017.68, 'symbol': 'kr'}, 'SGD': {'15m': 15933.58, 'last': 15933.58, 'buy': 15933.58, 'sell': 15933.58, 'symbol': '$'}, 'THB': {'15m': 366042.0, 'last': 366042.0, 'buy': 366042.0, 'sell': 366042.0, 'symbol': '฿'}, 'TRY': {'15m': 85021.27, 'last': 85021.27, 'buy': 85021.27, 'sell': 85021.27, 'symbol': '₺'}, 'TWD': {'15m': 341550.96, 'last': 341550.96, 'buy': 341550.96, 'sell': 341550.96, 'symbol': 'NT$'}}
{'USD': {'15m': 11616.04, 'last': 11616.04, 'buy': 11616.04, 'sell': 11616.04, 'symbol': '$'}, 'AUD': {'15m': 16205.74, 'last': 16205.74, 'buy': 16205.74, 'sell': 16205.74, 'symbol': '$'}, 'BRL': {'15m': 65301.28, 'last': 65301.28, 'buy': 65301.28, 'sell': 65301.28, 'symbol': 'R$'}, 'CAD': {'15m': 15303.79, 'last': 15303.79, 'buy': 15303.79, 'sell': 15303.79, 'symbol': '$'}, 'CHF': {'15m': 10588.28, 'last': 10588.28, 'buy': 10588.28, 'sell': 10588.28, 'symbol': 'CHF'}, 'CLP': {'15m': 9212683.9, 'last': 9212683.9, 'buy': 9212683.9, 'sell': 9212683.9, 'symbol': '$'}, 'CNY': {'15m': 80377.21, 'last': 80377.21, 'buy': 80377.21, 'sell': 80377.21, 'symbol': '¥'}, 'DKK': {'15m': 73255.41, 'last': 73255.41, 'buy': 73255.41, 'sell': 73255.41, 'symbol': 'kr'}, 'EUR': {'15m': 9864.6, 'last': 9864.6, 'buy': 9864.6, 'sell': 9864.6, 'symbol': '€'}, 'GBP': {'15m': 8866.84, 'last': 8866.84, 'buy': 8866.84, 'sell': 8866.84, 'symbol': '£'}, 'HKD': {'15m': 90027.47, 'last': 90027.47, 'buy': 90027.47, 'sell': 90027.47, 'symbol': '$'}, 'INR': {'15m': 870356.18, 'last': 870356.18, 'buy': 870356.18, 'sell': 870356.18, 'symbol': '₹'}, 'ISK': {'15m': 1601038.9, 'last': 1601038.9, 'buy': 1601038.9, 'sell': 1601038.9, 'symbol': 'kr'}, 'JPY': {'15m': 1231929.44, 'last': 1231929.44, 'buy': 1231929.44, 'sell': 1231929.44, 'symbol': '¥'}, 'KRW': {'15m': 13843360.88, 'last': 13843360.88, 'buy': 13843360.88, 'sell': 13843360.88, 'symbol': '₩'}, 'NZD': {'15m': 17753.7, 'last': 17753.7, 'buy': 17753.7, 'sell': 17753.7, 'symbol': '$'}, 'PLN': {'15m': 43410.94, 'last': 43410.94, 'buy': 43410.94, 'sell': 43410.94, 'symbol': 'zł'}, 'RUB': {'15m': 868955.96, 'last': 868955.96, 'buy': 868955.96, 'sell': 868955.96, 'symbol': 'RUB'}, 'SEK': {'15m': 102017.68, 'last': 102017.68, 'buy': 102017.68, 'sell': 102017.68, 'symbol': 'kr'}, 'SGD': {'15m': 15933.58, 'last': 15933.58, 'buy': 15933.58, 'sell': 15933.58, 'symbol': '$'}, 'THB': {'15m': 366042.0, 'last': 366042.0, 'buy': 366042.0, 'sell': 366042.0, 'symbol': '฿'}, 'TRY': {'15m': 85021.27, 'last': 85021.27, 'buy': 85021.27, 'sell': 85021.27, 'symbol': '₺'}, 'TWD': {'15m': 341550.96, 'last': 341550.96, 'buy': 341550.96, 'sell': 341550.96, 'symbol': 'NT$'}}

Program interrupted. (Use 'cont' to resume).
> d:\python38\lib\threading.py(309)wait()
-> return gotit
(Pdb)

EDIT: It appears you don’t need to issue the chcp 65001 command, just setting the PYTHONIOENCODING environment variable to utf-8 took care of the encoding issue.

0reactions
Voyzcommented, Aug 26, 2020

Fantastic you managed to figure this one out! Thanks for following up with the explanation - that explains everything. I nonetheless added a warning should someone have that encoding set incorrectly, as this may cause unexpected behaviour without being very verbose.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnicodeEncodeError: 'charmap' codec can't encode characters
I was getting the same UnicodeEncodeError when saving scraped web content to a file. To fix it I replaced this code:
Read more >
How to select this button using Python and Selenium?
Using Urllib in Python3 to download a file, giving HTTP error 403- faking a user agent? Why I'm getting "UnicodeEncodeError: 'charmap' codec can't...
Read more >
'charmap' codec can't encode character... - YouTube
SOLVED #PYTHON #ERROR UnicodeEncodeError : ' charmap ' codec can't encode character '\u266b' in position 157411: character maps to undefined ...
Read more >
ℎ - Nick Coghlan's Python Notes
with running Python scripts from your home directory on Windows). ... UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in ...
Read more >
loguru Documentation - Read the Docs
logger.debug("This message is not logged to the file") ... UnicodeEncodeError: 'charmap' codec can't encode character '\u5929' in position ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found