![]() So I tried to remove universal_newlines=True and decode/encode process input and output manually. I will be grateful if you can point me in the right direction or provide small example. But can not find a crossplatform way to find out which encoding to use. ![]() cyrillic on German system) error is raised. ![]() And when file path contains non-ASCII characters which are not available with current system encoding (e.g. UnicodeEncodeError: 'charmap' codec can't encode characters in position 53-59: character maps to Īs I understand, this is because I’m using universal_newlines=True and Python tries to decode process output using locale.getpreferredencoding(False) that is not utf-8 on Windows. Unfortunately, this does not work in Windows environment (Python 3.7.0 and Python 3.8, cmd.exe) if file path contains non-ASCII characters, error is Here is simplified code import subprocessĬommand = So I use subprocess.Popen() to start a process and then write()/ readline() to send data or retrieve result. I’m working on a Python wrapper around 3rd part command-line tool and need to exchange data with it via stdin/stdout.
0 Comments
Leave a Reply. |