DEV Community

loading...

Discussion on: How to convert .py to .exe? Step by step guide.

Collapse
eshleron profile image
Eshleron Author

Hi!
Please provide screenshots of errors or some code so I can help.

Collapse
qfactorin profile image
qFactorin

Hi, thank you for the quick response. I have attached the screenshots, attaching them again....

Thread Thread
qfactorin profile image
qFactorin

pasting the output for your reference:

Running auto-py-to-exe v2.7.11
Building directory: C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui
Provided command: pyinstaller --noconfirm --onefile --console "C:/Users/Srini/AppData/Local/qFactor/.spyproject/qFactor_finalVersion-working-beforemoving.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onefile --console C:/Users/Srini/AppData/Local/qFactor/.spyproject/qFactor_finalVersion-working-beforemoving.py --distpath C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui\application --workpath C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui\build --specpath C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui

22730 INFO: PyInstaller: 4.1
22735 INFO: Python: 3.7.9
22739 INFO: Platform: Windows-10-10.0.18362-SP0
22749 INFO: wrote C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui\qFactor_finalVersion-working-beforemoving.spec
22761 INFO: UPX is not available.
22769 INFO: Extending PYTHONPATH with paths
['C:\Users\Srini\AppData\Local\qFactor\.spyproject',
'C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui']
22815 INFO: checking Analysis
22820 INFO: Building Analysis because Analysis-00.toc is non existent
22825 INFO: Initializing module dependency graph...
22838 INFO: Caching module graph hooks...
22877 INFO: Analyzing base_library.zip ...
26058 INFO: Processing pre-find module path hook distutils from 'C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\hooks\pre_find_module_path\hook-distutils.py'.
26063 INFO: distutils: retargeting to non-venv dir 'C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib'
27755 INFO: Caching module dependency graph...
27864 INFO: running Analysis Analysis-00.toc
27903 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\Users\Srini\AppData\Local\Programs\Python\Python37\python.exe
28052 INFO: Analyzing C:\Users\Srini\AppData\Local\qFactor.spyproject\qFactor_finalVersion-working-beforemoving.py
28558 INFO: Processing pre-safe import module hook six.moves from 'C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-six.moves.py'.
30204 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-urllib3.packages.six.moves.py'.
An error occurred while packaging
Traceback (most recent call last):
File "C:\Users\Srini\Desktop\auto-py-to-exe-master\auto_py_to_exe\packaging.py", line 131, in package
run_pyinstaller()
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller_main.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller__main
.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 720, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 667, in build
exec(code, spec_namespace)
File "C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui\qFactor_finalVersion-working-beforemoving.spec", line 17, in
noarchive=False)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 242, in __init
_
self.postinit()
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in postinit
self.assemble()
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 413, in assemble
priority_scripts.append(self.graph.run_script(script))
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 304, in run_script
pathname)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1424, in run_script
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1497, in import_hook
source_package, target_module_partname, level)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1654, in _find_head_package
target_module_headname, target_package_name, source_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1498, in import_hook
target_module = self._load_tail(target_package, target_module_partname)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1717, in _load_tail
submodule = self._safe_import_module(head, mname, submodule)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1497, in import_hook
source_package, target_module_partname, level)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1654, in _find_head_package
target_module_headname, target_package_name, source_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1497, in import_hook
source_package, target_module_partname, level)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1654, in _find_head_package
target_module_headname, target_package_name, source_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2523, in _safe_import_hook
edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1514, in import_hook
target_module, target_attr_names):
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1808, in _import_importable_package_submodules
attr_name, submodule_name, package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1498, in import_hook
target_module = self._load_tail(target_package, target_module_partname)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1717, in _load_tail
submodule = self._safe_import_module(head, mname, submodule)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 431, in _safe_import_module
hook_module.pre_safe_import_module(hook_api)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-urllib3.packages.six.moves.py", line 33, in pre_safe_import_module
raise SystemExit("pre-safe-import-module hook failed, needs fixing.")
SystemExit: pre-safe-import-module hook failed, needs fixing.

Project output will not be moved to output folder
Complete.

Thread Thread
eshleron profile image
Eshleron Author

Thanks.
I have not encountered this one myself, but here is what I found

readthedocs.org/projects/pyinstall...

Search for "pre_safe_import_module". There is a description of the method that might help you.
If that doesn't help I would personally look for libs that may be broken or have a potential of being incorrectly imported.

Thread Thread
qfactorin profile image
qFactorin

Hi Eshleron, thank you for taking time and looking in to it. I managed to resolve the issue.
I was unsure of the conflict so have installed python from scratch on a new virtual machine and tried creating exe without installing any packages.

  1. Installed packages that were only part of error logs.
  2. finally found out that reason for the failure was related to hidden import "babel.numbers".
  3. included that as parameter in hidden imports in auto-py-to-exe, and boom everything worked........
Thread Thread
eshleron profile image
Eshleron Author

Glad you got it fixed!

Some comments have been hidden by the post's author - find out more