teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

4

動的リンクの場合について言及

2020/08/19 04:42

投稿

teamikl
teamikl

スコア8817

answer CHANGED
@@ -28,7 +28,9 @@
28
28
  ```
29
29
 
30
30
  上記のコードで、**LZW圧縮TIFFファイルの場合** 問題の再現を確認しました。
31
- ※ 他の形式では、対応するcodecsが無いと同様のエラーが起こる可能性はあります。対象のファイル次第。
31
+ ※ 他の形式では、対応するcodecsが無いと同様のエラーが起こる可能性はあります。対象のファイル
32
+ 次第。
33
+ ※ もし動的リンクでdllファイル等 が必要な場合は、追加で binaries への設定が必要です。
32
34
 
33
35
  ```python
34
36
  # pythonファイルで明示的インポート

3

問題の再現に用いたコードを追加

2020/08/19 04:42

投稿

teamikl
teamikl

スコア8817

answer CHANGED
@@ -21,6 +21,16 @@
21
21
  追記
22
22
 
23
23
  ```python
24
+ # 問題の再現に用いた最小限のコード
25
+ import tifffile
26
+ img = tifffile.imread("IN.tiff")
27
+ tifffile.imsave("OUT.tiff", img)
28
+ ```
29
+
30
+ 上記のコードで、**LZW圧縮TIFFファイルの場合** 問題の再現を確認しました。
31
+ ※ 他の形式では、対応するcodecsが無いと同様のエラーが起こる可能性はあります。対象のファイル次第。
32
+
33
+ ```python
24
34
  # pythonファイルで明示的インポート
25
35
 
26
36
  import imagecodecs._imcd

2

解決方法追記: imagecodecs._imcd を追加する

2020/08/19 02:47

投稿

teamikl
teamikl

スコア8817

answer CHANGED
@@ -15,4 +15,32 @@
15
15
  訂正
16
16
 
17
17
  lzw_decode 関数は、Python の関数で ./imagecodecs/_imagecodecs.py ファイル内にありました。
18
- C拡張ではありません。
18
+ C拡張ではありません。
19
+
20
+ ----
21
+ 追記
22
+
23
+ ```python
24
+ # pythonファイルで明示的インポート
25
+
26
+ import imagecodecs._imcd
27
+ ```
28
+
29
+ もしくは
30
+
31
+ ```
32
+ # pyinstaller のオプション or spec ファイル編集
33
+
34
+ --hidden-import=imagecodecs._imcd
35
+ ```
36
+
37
+ でどうでしょう。
38
+
39
+ ----
40
+ [When Things Go Wrong -- pyinstaller のトラブルシューティング](https://pyinstaller.readthedocs.io/en/stable/when-things-go-wrong.html)
41
+
42
+ - `python -v` で動的に読み込まれるモジュールを調べる
43
+ - imagecodecs._shared は存在したが、imagecodecs._imcd は含まれていなかった
44
+ - dist/APP_NAME/imagecodecs/ に _imcd を追加してみる → 動作成功
45
+ - 解決策A: pyinstaller が動的インポートを探せるように、明示的 import
46
+ - 解決策B: pyinstaller のオプション/ specファイル編集で指定する

1

情報訂正

2020/08/18 18:39

投稿

teamikl
teamikl

スコア8817

answer CHANGED
@@ -9,4 +9,10 @@
9
9
  pyd ファイルや dll ファイルを指定するといった流れ。
10
10
 
11
11
  pyファイルならpyinstallerが勝手に対応してくれるはずなので、
12
- 該当箇所はC拡張や外部ライブラリになってるのではないでしょうか。
12
+ 該当箇所はC拡張や外部ライブラリになってるのではないでしょうか。
13
+
14
+ ----
15
+ 訂正
16
+
17
+ lzw_decode 関数は、Python の関数で ./imagecodecs/_imagecodecs.py ファイル内にありました。
18
+ C拡張ではありません。