Will Truong
01/16/2023, 4:10 AMUnicodeEncodeError: 'charmap' codec can't encode characters in position 13-14: character maps to <undefined>
I think it would be the same problem with this one:
https://github.com/PrefectHQ/prefect/issues/5754
Thank you for your help!
Encountered exception during execution:
Traceback (most recent call last):
File "D:\python\lib\site-packages\prefect\engine.py", line 1445, in orchestrate_task_run
result = await run_sync(task.fn, *args, **kwargs)
File "D:\python\lib\site-packages\prefect\utilities\asyncutils.py", line 154, in run_sync_in_interruptible_worker_thread
async with anyio.create_task_group() as tg:
File "D:\python\lib\site-packages\anyio\_backends\_asyncio.py", line 662, in __aexit__
raise exceptions[0]
File "D:\python\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "D:\python\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "D:\python\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
result = context.run(func, *args)
File "D:\python\lib\site-packages\prefect\utilities\asyncutils.py", line 135, in capture_worker_thread_and_result
result = __fn(*args, **kwargs)
File "C:\Users\WILLTR~1\AppData\Local\Temp\tmpdl74duviprefect\prefect_test.py", line 106, in st1_extract_order_data
print('Client: ' + shop_name)
File "D:\python\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 13-14: character maps to <undefined>
Ryan Peden
01/16/2023, 7:59 AMPYTHONUTF8
environment variable to 1
usually solves it. This short writeup covers it pretty well.Will Truong
01/16/2023, 8:09 AMRyan Peden
01/16/2023, 8:17 AMset PYTHONUTF8=1
should work, but only in the console you enter it in. The Windows agent starts flows in subprocesses, and each subprocess gets its own process group that doesn't share the parent process' console. So I think setting the env variable globally as either a user or system variable is the most reliable way to do it.Will Truong
02/03/2023, 4:06 AM