###概要
プログラムのexe化に関して困っていることがあるので、教えてください。
NLTK含むプログラムをexe化したいと考えてpy2exeで以下のプログラムを走らせました。
test
1import nltk 2s = "Hi, I'm Taro Yamada I woke up at 8am" 3morph = nltk.word_tokenize(s) 4print(morph)
(https://qiita.com/m__k/items/ffd3b7774f2fde1083fa参照)
py2exe
1from distutils.core import setup 2import py2exe 3 4option = { 5 'compressed': 1, 6 'optimize': 2, 7 'bundle_files': 2, 8} 9 10setup( 11 options = { 12 'py2exe': option, 13 }, 14 console = [ 15 {'script': 'test.py'} 16 ], 17 zipfile = None, 18) 19
出来たプログラムを実行すると以下のエラーが発生しました。
Traceback (most recent call last): File "zipextimporter.pyc", line 87, in load_module zipimport.ZipImportError: can't find module 'numpy.random.mtrand' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "test.py", line 1, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 656, in _load_unlocked File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible File "zipextimporter.pyc", line 87, in load_module File "nltk\__init__.pyc", line 128, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 656, in _load_unlocked File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible File "zipextimporter.pyc", line 87, in load_module File "nltk\collocations.pyc", line 39, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 656, in _load_unlocked File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible File "zipextimporter.pyc", line 87, in load_module File "nltk\metrics\__init__.pyc", line 16, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 656, in _load_unlocked File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible File "zipextimporter.pyc", line 87, in load_module File "nltk\metrics\scores.pyc", line 15, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 656, in _load_unlocked File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible File "zipextimporter.pyc", line 87, in load_module File "scipy\__init__.pyc", line 61, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 656, in _load_unlocked File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible File "zipextimporter.pyc", line 87, in load_module File "numpy\__init__.pyc", line 151, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 656, in _load_unlocked File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible File "zipextimporter.pyc", line 87, in load_module File "numpy\random\__init__.pyc", line 179, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 656, in _load_unlocked File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible File "zipextimporter.pyc", line 87, in load_module File "numpy\random\_pickle.pyc", line 1, in <module> File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 656, in _load_unlocked File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible File "zipextimporter.pyc", line 112, in load_module SystemError: initialization of numpy.random.mtrand did not return an extension module
どのようなエラーの内容なのでしょうか?
回避方法を知りたいです。お願いします。
###環境
Windows10 64bit
nltk=3.6.2 version
pyinstallerの使用はしたくありません。(速度と容量の関係上)
###補足
新しく出たエラー
log
1Traceback (most recent call last): 2 File "test.py", line 1, in <module> 3 File "<frozen importlib._bootstrap>", line 971, in _find_and_load 4 File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked 5 File "<frozen importlib._bootstrap>", line 656, in _load_unlocked 6 File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible 7 File "nltk\__init__.pyc", line 142, in <module> 8 File "<frozen importlib._bootstrap>", line 971, in _find_and_load 9 File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked 10 File "<frozen importlib._bootstrap>", line 656, in _load_unlocked 11 File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible 12 File "nltk\chunk\__init__.pyc", line 157, in <module> 13 File "<frozen importlib._bootstrap>", line 971, in _find_and_load 14 File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked 15 File "<frozen importlib._bootstrap>", line 656, in _load_unlocked 16 File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible 17 File "nltk\chunk\api.pyc", line 13, in <module> 18 File "<frozen importlib._bootstrap>", line 971, in _find_and_load 19 File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked 20 File "<frozen importlib._bootstrap>", line 656, in _load_unlocked 21 File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible 22 File "nltk\parse\__init__.pyc", line 100, in <module> 23 File "<frozen importlib._bootstrap>", line 971, in _find_and_load 24 File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked 25 File "<frozen importlib._bootstrap>", line 656, in _load_unlocked 26 File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible 27 File "nltk\parse\transitionparser.pyc", line 19, in <module> 28 File "<frozen importlib._bootstrap>", line 971, in _find_and_load 29 File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked 30 File "<frozen importlib._bootstrap>", line 656, in _load_unlocked 31 File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible 32 File "sklearn\__init__.pyc", line 80, in <module> 33 File "<frozen importlib._bootstrap>", line 971, in _find_and_load 34 File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked 35 File "<frozen importlib._bootstrap>", line 656, in _load_unlocked 36 File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible 37 File "sklearn\_distributor_init.pyc", line 23, in <module> 38 File "ctypes\__init__.pyc", line 348, in __init__ 39OSError: [WinError 126] 指定されたモジュールが見つかりません。
py2exe
1from distutils.core import setup 2import py2exe 3 4option = { 5 'compressed': 1, 6 'optimize': 2, 7 'bundle_files': 2, 8} 9 10 11setup( 12 options = { 13 'py2exe': { 14 'bundle_files': 3, 15 'optimize': 2, 16 'includes': ["nltk"] 17 } 18 }, 19 windows = [{'script': 'test.py'}], 20)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/06/22 14:07