回答編集履歴
7
追記
answer
CHANGED
@@ -34,4 +34,6 @@
|
|
34
34
|
|
35
35
|
3, あと`python`ファイルの内容が分からないので、念のために記載しますが、
|
36
36
|
`Windows`環境で`MultiProcess`や`ProcessPoolExecutor`をもし使用しているなら、
|
37
|
-
`freeze_support`を追加記述することをお忘れなく。
|
37
|
+
`freeze_support`を追加記述することをお忘れなく。
|
38
|
+
■参考情報
|
39
|
+
[multiprocessing#freeze_support](https://docs.python.jp/3/library/multiprocessing.html#multiprocessing.freeze_support)
|
6
追記
answer
CHANGED
@@ -13,15 +13,11 @@
|
|
13
13
|
|
14
14
|
---
|
15
15
|
|
16
|
+
1,まず、`--onefile`オプションなし(※)で`pyinstaller`でexeファイルを生成し、
|
16
|
-
|
17
|
+
`dist/apifile`フォルダ直下にモデルファイルが格納されることを確認してくださいな。
|
17
|
-
ファイルがapifileフォルダ直下に配置されていないといけないので。
|
18
|
-
※格納されているのが確認できれば、--onefileのオプションをつけ直してください。
|
18
|
+
※格納されているのが確認できれば、`--onefile`のオプションをつけ直してください。
|
19
19
|
|
20
|
-
2,上記で格納されていてアプリケーション側でパスが上手く取れない時は以下のような形で取得してみてください。
|
20
|
+
2,上記で格納されていてアプリケーション側でパスが上手く取れない時は以下のような形でパスを取得してみてください。
|
21
|
-
あとpythonファイルの内容が分からないので、念のために記載しますが、
|
22
|
-
Winwdos環境でMultiProcessやProcessPoolExecutorをもし使用しているなら、
|
23
|
-
freeze_supportを追加記述することをお忘れなく。
|
24
|
-
|
25
21
|
```Python
|
26
22
|
from pathlib import Path
|
27
23
|
import sys
|
@@ -34,4 +30,8 @@
|
|
34
30
|
model_file = Path(APPLICATION_PATH, "model.sav")
|
35
31
|
```
|
36
32
|
■参考情報
|
37
|
-
[Run-time Information](http://pyinstaller.readthedocs.io/en/stable/runtime-information.html)
|
33
|
+
[Run-time Information](http://pyinstaller.readthedocs.io/en/stable/runtime-information.html)
|
34
|
+
|
35
|
+
3, あと`python`ファイルの内容が分からないので、念のために記載しますが、
|
36
|
+
`Windows`環境で`MultiProcess`や`ProcessPoolExecutor`をもし使用しているなら、
|
37
|
+
`freeze_support`を追加記述することをお忘れなく。
|
5
追記
answer
CHANGED
@@ -13,8 +13,9 @@
|
|
13
13
|
|
14
14
|
---
|
15
15
|
|
16
|
-
1,まず、--onefileオプションをやめて、pyinstallerでexeを生成してdist/win/apifile フォルダにモデルファイルが格納されることを確認してくださいな。
|
16
|
+
1,まず、--onefileオプションをやめて(※)、pyinstallerでexeを生成してdist/win/apifile フォルダにモデルファイルが格納されることを確認してくださいな。
|
17
17
|
ファイルがapifileフォルダ直下に配置されていないといけないので。
|
18
|
+
※格納されているのが確認できれば、--onefileのオプションをつけ直してください。
|
18
19
|
|
19
20
|
2,上記で格納されていてアプリケーション側でパスが上手く取れない時は以下のような形で取得してみてください。
|
20
21
|
あとpythonファイルの内容が分からないので、念のために記載しますが、
|
4
補足
answer
CHANGED
@@ -14,9 +14,9 @@
|
|
14
14
|
---
|
15
15
|
|
16
16
|
1,まず、--onefileオプションをやめて、pyinstallerでexeを生成してdist/win/apifile フォルダにモデルファイルが格納されることを確認してくださいな。
|
17
|
-
ファイルがapifileフォルダに
|
17
|
+
ファイルがapifileフォルダ直下に配置されていないといけないので。
|
18
18
|
|
19
|
-
2,上記で
|
19
|
+
2,上記で格納されていてアプリケーション側でパスが上手く取れない時は以下のような形で取得してみてください。
|
20
20
|
あとpythonファイルの内容が分からないので、念のために記載しますが、
|
21
21
|
Winwdos環境でMultiProcessやProcessPoolExecutorをもし使用しているなら、
|
22
22
|
freeze_supportを追加記述することをお忘れなく。
|
@@ -31,4 +31,6 @@
|
|
31
31
|
APPLICATION_PATH = str(Path(__file__).parent)
|
32
32
|
|
33
33
|
model_file = Path(APPLICATION_PATH, "model.sav")
|
34
|
-
```
|
34
|
+
```
|
35
|
+
■参考情報
|
36
|
+
[Run-time Information](http://pyinstaller.readthedocs.io/en/stable/runtime-information.html)
|
3
追記
answer
CHANGED
@@ -30,5 +30,5 @@
|
|
30
30
|
else:
|
31
31
|
APPLICATION_PATH = str(Path(__file__).parent)
|
32
32
|
|
33
|
-
model_file = Path(APPLICATION_PATH, "model.sav
|
33
|
+
model_file = Path(APPLICATION_PATH, "model.sav")
|
34
34
|
```
|
2
追記
answer
CHANGED
@@ -9,4 +9,26 @@
|
|
9
9
|
■参考情報
|
10
10
|
- [pythonのGUIアプリを.exe化](https://qiita.com/yukiozawa/items/dd87ed281ea81d972e16)
|
11
11
|
- [Adding Data Files](http://pyinstaller.readthedocs.io/en/stable/spec-files.html#adding-data-files)
|
12
|
-
- [What to bundle, where to search](http://pyinstaller.readthedocs.io/en/stable/usage.html#options-group-what-to-bundle-where-to-search)
|
12
|
+
- [What to bundle, where to search](http://pyinstaller.readthedocs.io/en/stable/usage.html#options-group-what-to-bundle-where-to-search)
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
1,まず、--onefileオプションをやめて、pyinstallerでexeを生成してdist/win/apifile フォルダにモデルファイルが格納されることを確認してくださいな。
|
17
|
+
ファイルがapifileフォルダにコピーされていないといけないので。
|
18
|
+
|
19
|
+
2,上記で問題なく、アプリケーションパスが上手く取れない時は以下のような形で取得してみてください。
|
20
|
+
あとpythonファイルの内容が分からないので、念のために記載しますが、
|
21
|
+
Winwdos環境でMultiProcessやProcessPoolExecutorをもし使用しているなら、
|
22
|
+
freeze_supportを追加記述することをお忘れなく。
|
23
|
+
|
24
|
+
```Python
|
25
|
+
from pathlib import Path
|
26
|
+
import sys
|
27
|
+
|
28
|
+
if getattr(sys, 'frozen', False):
|
29
|
+
APPLICATION_PATH = sys._MEIPASS
|
30
|
+
else:
|
31
|
+
APPLICATION_PATH = str(Path(__file__).parent)
|
32
|
+
|
33
|
+
model_file = Path(APPLICATION_PATH, "model.sav'")
|
34
|
+
```
|
1
追記
answer
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
mac環境は持ってないので、憶測回答になってしまいますが。
|
2
2
|
|
3
3
|
モデルファイルも一緒に配布したいという要件と認識して回答します。
|
4
|
-
apifile.specファイルのdatasオプションに値を設定していないのではないでしょうか。
|
4
|
+
`apifile.spec`ファイルの`datas`オプションに値を設定していないのではないでしょうか。
|
5
5
|
|
6
6
|
`pyinstaller --add-data ./data.hdf5;.`として--add-dataオプションを使用してモデルを含める形にしてみてはどうでしょうか。
|
7
7
|
|
8
|
-
`apifile.spec`ファイルの`datas`オプションでも指定可能です。
|
8
|
+
`apifile.spec`ファイル内の`datas`オプションでも指定可能です。
|
9
9
|
■参考情報
|
10
10
|
- [pythonのGUIアプリを.exe化](https://qiita.com/yukiozawa/items/dd87ed281ea81d972e16)
|
11
|
-
- [Adding Data Files](http://pyinstaller.readthedocs.io/en/stable/spec-files.html#adding-data-files)
|
11
|
+
- [Adding Data Files](http://pyinstaller.readthedocs.io/en/stable/spec-files.html#adding-data-files)
|
12
|
+
- [What to bundle, where to search](http://pyinstaller.readthedocs.io/en/stable/usage.html#options-group-what-to-bundle-where-to-search)
|