Reputation: 133
I want to convert .py to .exe. For that I got to know that auto-py-to-exe is simple and works for Python >= 2.7 ( including 3.7 🎉 ). When I tried to convert a simple application it worked smoothly (auto-py-exe is working ) . But when I try to convert my original python scripts its throwing error:
An error occurred, traceback follows:
Traceback (most recent call last):
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
yield
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_dll.py", line 26, in _LoadLibraryEx
function_name='LoadLibraryEx')
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_util.py", line 81, in __call__
self._raise_error(function_name)
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_util.py", line 92, in _raise_error
raise exception
OSError: [WinError 2] The system cannot find the file specified
Its my first time converting a code into .exe so I have no idea what to do now (excepting searching on web). I don't even know what is causing this error. I have doubt on mayavi but not sure. Anyhelp will be highly welcomed.
Program: python 3.7
GUI : PyQt5
Libraries included: mayavi,opencv,matplotlib,PIL,pylab,scipy,etc
Command to convert: pyinstaller -y "path_to_script.py"
Edits: I'm sure its due to mayavi as the simplest code attached didn't convert into .exe ( Sorry for lengthy post ! ) Its due to mayavi but I still want solution for this, Thanks in advance for any suggestions.
Code:
import numpy as np
from mayavi.mlab import contour3d
from mayavi import mlab
x, y, z = np.ogrid[-3:3:60j, -3:3:60j, -3:3:60j]
H1 = 0.45+x**2+y**2-z**2
obj1 = contour3d(H1, contours=[0], transparent=False)
mlab.show()
Command to convert: pyinstaller -y "path_to_script.py"
Error:
An error occurred, traceback follows:
Traceback (most recent call last):
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
yield
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_dll.py", line 26, in _LoadLibraryEx
function_name='LoadLibraryEx')
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_util.py", line 81, in __call__
self._raise_error(function_name)
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\core\cffi\_util.py", line 92, in _raise_error
raise exception
OSError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\lab_pc\anaconda3\lib\site-packages\auto_py_to_exe\__main__.py", line 269, in convert
pyi.run() # Execute PyInstaller
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
exec(code, spec_namespace)
File "C:\Users\lab_pc\AppData\Local\Temp\tmp_0mronij\stackoverflow_ask_py2exe.spec", line 17, in <module>
noarchive=False)
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
self.__postinit__()
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 567, in assemble
redirects=self.binding_redirects))
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 231, in Dependencies
for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 407, in getAssemblyFiles
for assembly in getAssemblies(pth):
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 358, in getAssemblies
res = GetManifestResources(pth)
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1005, in GetManifestResources
return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
File "c:\users\lab_pc\anaconda3\lib\site-packages\PyInstaller\utils\win32\winresource.py", line 168, in GetResources
hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
File "c:\users\lab_pc\anaconda3\lib\contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "c:\users\lab_pc\anaconda3\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (2, 'LoadLibraryEx', 'The system cannot find the file specified')
Project output will not be moved to output folder
Complete.
Should I use some different tool to convert? (Suggestions please in context to my problem). Thanks
Upvotes: 2
Views: 1526