Python Pathlib在Unicode符号上崩溃iff程序与PyInstaller打包

Python Pathlib在Unicode符号上崩溃iff程序与PyInstaller打包,python,python-3.x,character-encoding,pyinstaller,pathlib,Python,Python 3.x,Character Encoding,Pyinstaller,Pathlib,我的python程序创建一个锁文件: output_file_path = Path(output_folder_path, filename) Path(output_file_path.as_posix() + ".lock").touch() 请注意,文件名包含德语unicode字符。 如果我在PyCharm中执行此操作,一切正常 但是,当且仅当我使用以下内容创建可执行文件时: python3 -m PyInstaller --onefile main.py 然

我的python程序创建一个锁文件:

output_file_path = Path(output_folder_path, filename)

Path(output_file_path.as_posix() + ".lock").touch()
请注意,文件名包含德语unicode字符。 如果我在PyCharm中执行此操作,一切正常

但是,当且仅当我使用以下内容创建可执行文件时:

 python3 -m PyInstaller --onefile main.py
然后在执行时,这将引发:

File "pathlib.py", line 1295, in touch
UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 57: ordinal not in range(128)
这要么是我的代码、pathlib、pyinstaller的问题,要么是我组合它们的方式的问题

编辑:我被要求提供一个最小的可复制示例:

from pathlib import Path
Path("/tmp/", "This should be a valid file: üöä").touch()
upper语句在PyCharm中工作,但在打包程序中引发异常

我该如何解决这个问题


(我更愿意“正确”地执行此操作,而不是简单地删除所有unicode字符。)

哪种操作系统?Manjaro Linux。脚本由systemd执行。在systemd中执行脚本的用户的
区域设置是什么?
en_DE.UTF-8
(systemd在--user模式下运行)请您的问题提供答案。