内容:
Debian12ベースのDockerイメージ上でxlsファイルを開く際にAspose内で例外が発生して開けない
環境
# cat /etc/os-release
PRETTY_NAME=“Debian GNU/Linux 12 (bookworm)”
NAME=“Debian GNU/Linux”
VERSION_ID=“12”
VERSION=“12 (bookworm)”
VERSION_CODENAME=bookworm
ID=debian
HOME_URL=“https://www.debian.org/”
SUPPORT_URL=“Debian -- User Support”
BUG_REPORT_URL=“https://bugs.debian.org/”
# python -V
Python 3.11.9
手順
1.Dockerfileで「FROM python:3.11」を指定し、Dockerイメージをビルドします。
2.Docker内にログインし、以下をインストールします。
apt install locales-all libicu-dev icu-devtools
pip install aspose-cells aspose-cells-python
※Aspose.Cells 24.6.0がインストールされる
3.以下のコードを配置(aspose_test.py)して実行します。
import aspose.cells
import locale
locale.setlocale(locale.LC_ALL, 'ja_JP.utf8')
current_locale = locale.getlocale()
print(current_locale)
with aspose.cells.Workbook('test.xls') as wb:
pass
■結果
# python aspose_test.py
Process terminated. Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
at System.Environment.FailFast(System.String)
at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
at System.Globalization.GlobalizationMode..cctor()
at System.Globalization.CultureData.CreateCultureWithInvariantData()
at System.Globalization.CultureData.get_Invariant()
at System.Globalization.CultureInfo..cctor()
at System.StringComparer..cctor()
at System.StringComparer.get_OrdinalIgnoreCase()
at System.Text.EncodingTable..cctor()
at System.Text.EncodingTable.GetCodePageFromName(System.String)
at System.Text.CodePagesEncodingProvider.GetEncoding(System.String)
at System.Text.EncodingProvider.GetEncodingFromProvider(System.String)
at System.Text.Encoding.GetEncoding(System.String)
at Aspose.WrpGen.Interop.GenericMarshaler..cctor()
at Aspose.WrpGen.Interop.GenericMarshaler.ToString(Aspose.WrpGen.Interop.PyStringArg*)
at WrpNs_Aspose.WrpNs_Cells.WrpCs_Workbook_8390C5AB.ctor_002_Workbook(Aspose.WrpGen.Interop.PyStringArg*)
Aborted (core dumped)
4.続いて「export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1」を実行後、再度aspose_test.pyを実行します
# python aspose_test.py
('ja_JP', 'UTF-8')
Traceback (most recent call last):
File "/home/root/aspose_test.py", line 8, in <module>
with aspose.cells.Workbook('test.xls') as wb:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Proxy error(CultureNotFoundException): Culture is not supported. (Parameter 'culture')
1041 (0x0411) is an invalid culture identifier.
要望
Debian12のDockerイメージ環境でxlsファイルを開く際のエラー回避方法を教えてください