Call pvbatch.exe from a Python script with as argument a file path containing Japanese characters


I want to call pvbatch.exe (on Windows) to create a VTU file, since I use a GUI, I don’t want to block during the process. So, I use the below code:

args = [PARAVIEW_PATH, input_file_path]
self.paraview_process = subprocess.Popen(args)

It works well with usual paths, but if the input_file_path contains a Japanese character, I got the below error:

['C:/Program Files/ParaView 5.9.1-Windows-Python3.8-msvc2017-64bit/bin/pvbatch.exe', 'C:\\Users\\arnaud\\Source\\Repos\\geoinfo\\src\\results\\20220102115342ワーク\\make_vtu_test_sample_temperature_20220102115342ワーク.py']
C:/Program Files/ParaView 5.9.1-Windows-Python3.8-msvc2017-64bit/bin\vtkpython: can't open file 'C:\Users\arnaud\Source\Repos\geoinfo\src\results\20220102115342���[�N\make_vtu_test_sample_temperature_20220102115342���[�': [Errno 2] No such file or directory

I report this problem as a bug (see issue link below), but it seems to be a Windows problem.

I use Python 3.7 and ParaView 5.9.1 or ParaView 5.10.0-RC1.

If I use below code:

args = [PARAVIEW_PATH.encode(), input_file_path.encode()]
self.paraview_process = subprocess.Popen(args)

I get: a bytes-like object is required, not 'str'.

Does anyone know how I can solve this problem ?

Thank you

It seems like there’s some mojibake going on. Everything in VTK is expected to be UTF-8. Recently, work was done to accept filepaths in some places which skips the requirement. I think this showed up in 5.10 at some point, but anything older won’t support it.

There is a problem with pvpython and pvbatch processing non-English characters on Windows. I’m testing a fix for this.

What recent changes to VTK skip the requirement for utf-8 encoded file paths?

I can’t see where VTK_FILEPATH is defined, so I don’t see how it changes the utf-8 file name requirement.

I have discovered that 5 people have introduced changes to VTK over the past year for opening files and streams which are not unicode compliant. It is annoying that 3 of those people are Kitware staff!

This has been fixed now.