Reputation: 31
I had successfully compiled my script: main.py using PyInstaller. However when I tried to run the main.exe application under dist/main directory, I got the below error:
C:\test\trunk\testalgorithm\testengine\dist\main>main.exe
Traceback (most recent call last):
File "testengine\main.py", line 2, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "c:\users\bot\appdata\local\programs\python\python35\lib\site-packages\Py
Installer\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "testengine\K.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "c:\users\bot\appdata\local\programs\python\python35\lib\site-packages\Py
Installer\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "testengine\backend\data_retrieval.py", line 6, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "c:\users\bot\appdata\local\programs\python\python35\lib\site-packages\Py
Installer\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "alertsengine\backend\log_config.py", line 10, in <module>
File "logging\__init__.py", line 1008, in __init__
File "logging\__init__.py", line 1037, in _open
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\test\\trunk\\testalgorithm\\testengine\\dist\\main\\logs\\LOG_17_07_05_24_2017.log'
Failed to execute script main
I dont know what it means by there's no log files.
Did I miss something? Appreciate your help!
Upvotes: 3
Views: 16018
Reputation: 3104
You might want to edit your spec file.
After running pyinstaller main.py
, go to the main folder and add your log folder as Data Files to your main.spec file. It should look, in your case, something like this:
added_files = [
( './logs', 'logs' )
]
a = Analysis(...
datas=added_files,
...
)
After that, run pyinstaller main.spec
to redistribute your app.
Note that you'd probably have to have more add data files after that. You may read more here
Upvotes: 6