# How Can I read non-ascii FileNames from pvpython

**URL:** https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121
**Category:** ParaView Support
**Tags:** python
**Created:** [December 5, 2019, 8:32am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121 "2019-12-05T08:32:51Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [December 5, 2019, 8:32am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/1 "2019-12-05T08:32:51Z")

</div>

Hi guys,

I have save a .py state file from File-\>Save State…， with only one ply reader proxy in current state:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/9/96c72d6d716dab9d4a8bb6c078aff3a2b8570da9.png)  
note its FileName is not an ascii-encodable string. Then I got the py state file containing following lines:

```
# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------

# create a new 'PLY Reader'
ply = PLYReader(FileNames=['C:/tmp/??-.ply'])

```

This state file cannot be loaded back through File-\> Load State…  
This situation is just same as my requirement to read file with non-ascii character in its path, so my question is how can I load such files through python scripts: macros, state files or especially **using pvpython.exe for offscreen processing**?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [December 5, 2019, 8:47am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/2 "2019-12-05T08:47:58Z")

</div>

> This state file cannot be loaded back through File-\> Load State…

Indeed, nice find. Issue logged here :  
[https://gitlab.kitware.com/paraview/paraview/issues/19504](https://gitlab.kitware.com/paraview/paraview/issues/19504)

A work around I can think of is to edit the python state file manually to correct the non-utf8 char.  
Another work around would be to use the python trace feature instead of the python state.

---

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [December 5, 2019, 8:58am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/3 "2019-12-05T08:58:03Z")

</div>

Thanks for your reply

I have just tested Trace, it correctly generate the write code:

```
# create a new 'PLY Reader'
ply = PLYReader(FileNames=['C:/tmp/中.ply'])

```

but it cannot run through “python shell -\> run scripts”, error message is:

```
Warning: In D:\ParaView56\VTK\IO\PLY\vtkPLYReader.cxx, line 135
vtkPLYReader (000001F667E1AFE0): Could not open PLY file

ERROR: In D:\ParaView56\VTK\Common\ExecutionModel\vtkExecutive.cxx, line 782
vtkPVCompositeDataPipeline (000001F6691B2040): Algorithm vtkFileSeriesReader(000001F6691B2130) returned failure for request: vtkInformation (000001F66964F970)
  Debug: Off
  Modified Time: 625380
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_DATA
  FORWARD_DIRECTION: 0
  ALGORITHM_AFTER_FORWARD: 1
  FROM_OUTPUT_PORT: 0

```

It seems that even the character ‘中’ is encoded correctly in .py file, python interpretor still cannot decode this character correctly from py file.

Is there any way to specify encoding system for python interpretor embeded in paraview?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [December 5, 2019, 9:03am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/4 "2019-12-05T09:03:21Z")

</div>

I can’t reproduce this issue with ParaView 5.7.0. Can you download it and try with it :  
[https://www.paraview.org/download/](https://www.paraview.org/download/)

---

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [December 5, 2019, 9:41am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/5 "2019-12-05T09:41:32Z")

</div>

Hi Mathieu,  
I have downloaded 5.7 version at  
[https://www.paraview.org/paraview-downloads/download.php?submit=Download&version=v5.7&type=binary&os=Windows&downloadFile=ParaView-5.7.0-Windows-Python3.7-msvc2015-64bit.zip](https://www.paraview.org/paraview-downloads/download.php?submit=Download&version=v5.7&type=binary&os=Windows&downloadFile=ParaView-5.7.0-Windows-Python3.7-msvc2015-64bit.zip)

After same process(Trace-\> python shell -\> run scripts), I still got same result, here is the screenshot, filename is not decoded correctly:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/1/1af62f77da1fdc84a025d79adea120834848fe98.png)

Maybe system encoding of my OS(Windows) is different from yours?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [December 5, 2019, 9:58am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/6 "2019-12-05T09:58:45Z")

</div>

> Maybe system encoding of my OS(Windows) is different from yours?

That’s a possibility, I’m using a Linux in en\_US\_UTF8.

---

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [December 5, 2019, 10:56am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/7 "2019-12-05T10:56:50Z")

</div>

So Is there some thing I can do to read these files from python scripts, maybe specify coding system through paraview command line or compile a utf-8 version by changing some cmake configuration? after all I definately cannot go steal your computer:)

I have tested add “# -_- coding: utf-8 -_-” to the scripts, but it does not work

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [December 5, 2019, 12:03pm UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/8 "2019-12-05T12:03:04Z")

</div>

Which version of windows and which language are you using ?

---

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [December 6, 2019, 2:06am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/9 "2019-12-06T02:06:32Z")

</div>

Hi Mathieu,  
My OS version is Windows10 1803, Language is Chinese(Simplified).

**I have test another option may help us to address this issue:**  
In Windows Settings, there is an option introduced since Windows 1803 update package:  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/f/ffdcc0900823473ee3f613411ca2e716f31f6ed0.png)  
which on my computer like this:  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/9/91e356a363d5503149e509e479f1a3936cc84c61.png)

with this check box checked, pvpython scripts **can** read files with non-ascii character in its path, but unfortunately, this option may cause error on other daily-use applications.

Based on information in the dialog above, it seems that Windows treats ParaView as “programs that do not support Unicode” which apperantly not true, so may be we explicitly tell Operation system that ParaView is capable of supporting unicode may fix this problem without enable that option system-wide?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [December 6, 2019, 8:23am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/10 "2019-12-06T08:23:03Z")

</div>

That’s really interesting information here. Thanks for your debug. I will investigate this.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [March 20, 2020, 11:01pm UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/11 "2020-03-20T23:01:38Z")

</div>

I think the work done by @todoooo in 5.8 should have resolved most of these issues. Is 5.8 working for you?

---

<div class="post-metadata">

### Author: ![todoooo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/todoooo/32/2819_2.png) [@todoooo](https://discourse.paraview.org/u/todoooo)
#### Post date: [March 21, 2020, 12:13am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/12 "2020-03-21T00:13:01Z")

</div>

@ymjia The unicode changes are not in Paraview 5.8, but if you build from the master branch of Paraview and VTK this problem is fixed. There’s no need to force Windows to use a global UTF-8 setting.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [March 21, 2020, 12:29am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/13 "2020-03-21T00:29:43Z")

</div>

Ah, right. Forgot they came in late in the 5.8 cycle. They’ll be in 5.9 though (due out in the fall).

---

<div class="post-metadata">

### Author: ![todoooo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/todoooo/32/2819_2.png) [@todoooo](https://discourse.paraview.org/u/todoooo)
#### Post date: [March 21, 2020, 9:22pm UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/14 "2020-03-21T21:22:14Z")

</div>

@ymjia In the meantime you can try this solution for Windows 10. It provides a _per-process_ utf8 setting.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/7/702cb88c7ced55a69d2b5e9aad723ec3e0daa90f.png)  
[https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page](https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page)

---

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [April 10, 2020, 11:33am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/15 "2020-04-10T11:33:52Z")

</div>

Thanks for your reply, I have tested master(12606e87b7bd9b258c79f9146a48b001541fffb0) cloned today(2020.04.10).  
Things seems got worse:  
I compiled from master, it can read files with all ascii charactors path, but when I try to open a file with non-ascii char, here is the gif:

 ![pv_encode](https://discourse.paraview.org/uploads/default/original/2X/4/4810d075781cb9a62db218708cdb837bd1a90fce.gif)

If I drag that file in, ParaView will print error message:

 ![drag](https://discourse.paraview.org/uploads/default/original/2X/4/41c859d67b480984fcea2abddbac21b5f83ca3f0.gif)

I have tested both the windows installer [here](https://www.paraview.org/paraview-downloads/download.php?submit=Download&version=v5.8&type=binary&os=Windows&downloadFile=ParaView-5.8.0-Windows-Python3.7-msvc2015-64bit.exe) and compiled version from master, error message is same.

I have a version 5.6 build, in my pc, it can read this file:

 ![pv56](https://discourse.paraview.org/uploads/default/original/2X/d/db34d2a911f62560ce235830180f9f6eff34b6ec.gif)

So Is there somothing I have missed in CMake Configuration or Operating System settings?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 10, 2020, 12:11pm UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/16 "2020-04-10T12:11:59Z")

</div>

Looks like a regression.

@Joachim_Pouderoux

---

<div class="post-metadata">

### Author: ![todoooo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/todoooo/32/2819_2.png) [@todoooo](https://discourse.paraview.org/u/todoooo)
#### Post date: [April 10, 2020, 10:17pm UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/17 "2020-04-10T22:17:32Z")

</div>

Did you also build from VTK master?

---

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [April 11, 2020, 8:48am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/18 "2020-04-11T08:48:54Z")

</div>

yes, I have update submodule recursively, current git node in my local repo is af056c90caf6d553c6ebe9e2f430bd23c85a524c (2020.04.08 by Charles Gueunet)

---

<div class="post-metadata">

### Author: ![todoooo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/todoooo/32/2819_2.png) [@todoooo](https://discourse.paraview.org/u/todoooo)
#### Post date: [April 12, 2020, 12:45am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/19 "2020-04-12T00:45:42Z")

</div>

I suppose the Paraview master branch still builds against an official release of VTK (possibly 8.2) Perhaps @cory.quammen can shed some light on this?

Just out of interest what is the code page setting on your Windows machine?

What’s the full stack trace for that error?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [April 12, 2020, 3:21am UTC](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121/20 "2020-04-12T03:21:40Z")

</div>

ParaView `master` tracks VTK `master` pretty closely. For ParaView releases, there’s a branch in VTK to track that (mainly handled by ParaView developers rather than bothering the normal development process).

[Next page](https://discourse.paraview.org/t/how-can-i-read-non-ascii-filenames-from-pvpython/3121.md?page=2)
