Python Forum
Convert my .py to .exe but failed to execute - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/Forum-Python-Coding)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/Forum-Web-Scraping-Web-Development)
+--- Thread: Convert my .py to .exe but failed to execute (/Thread-Convert-my-py-to-exe-but-failed-to-execute)



Convert my .py to .exe but failed to execute - gahhon - Feb-11-2019

pyinstaller -w -F iApplication.py
As the source and tutorial from this Covert PY to EXE
It will generated 3 folders and 1 .spec file.
As I know, the .exe would be stored in dist folder, but I can't execute it. It said failed to execute.

But then, when compiling the iApplication.py (executing pyinstaller command)
It popped a lot of WARNING issue regarding missing LIB.

Capture


Please kindly advise. Thanks.


RE: Convert my .py to .exe but failed to execute - gahhon - Feb-14-2019

anyone?


RE: Convert my .py to .exe but failed to execute - metulburr - Feb-17-2019

copy and paste the entire error here in code tags, not a screenshot. The beginning and the end are the most important, and i cant see either.

Also what is every 3rd party library in your code? I know selenium, but are there any others?

Look through open and closed issues on pyinstaller for anything relevant to yours. Thats where i would start when you post the full error.


RE: Convert my .py to .exe but failed to execute - gahhon - Feb-18-2019

(Feb-17-2019, 06:21 PM)metulburr Wrote: copy and paste the entire error here in code tags, not a screenshot. The beginning and the end are the most important, and i cant see either.

Also what is every 3rd party library in your code? I know selenium, but are there any others?

Look through open and closed issues on pyinstaller for anything relevant to yours. Thats where i would start when you post the full error.


C:\Users\Jack Wong\Desktop\Python>pyinstaller -w -F pbb.py
61 INFO: PyInstaller: 3.4
61 INFO: Python: 3.7.2
61 INFO: Platform: Windows-10-10.0.17134-SP0
67 INFO: wrote C:\Users\Jack Wong\Desktop\Python\pbb.spec
69 INFO: UPX is not available.
70 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Jack Wong\\Desktop\\Python',
 'C:\\Users\\Jack Wong\\Desktop\\Python']
71 INFO: checking Analysis
71 INFO: Building Analysis because Analysis-00.toc is non existent
71 INFO: Initializing module dependency graph...
73 INFO: Initializing module graph hooks...
79 INFO: Analyzing base_library.zip ...
4824 INFO: running Analysis Analysis-00.toc
4832 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\jack wong\appdata\local\programs\python\python37\python.exe
4910 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python.exe
4978 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python.exe
5046 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python.exe
5113 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python.exe
5178 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python.exe
5366 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
5433 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
5499 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
5565 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
5637 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
5702 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
5769 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
5840 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
5913 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
5978 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
6047 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
6114 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
6189 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\VCRUNTIME140.dll
6256 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\VCRUNTIME140.dll
6324 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\VCRUNTIME140.dll
6391 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\VCRUNTIME140.dll
6458 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\VCRUNTIME140.dll
6463 INFO: Caching module hooks...
6468 INFO: Analyzing C:\Users\Jack Wong\Desktop\Python\pbb.py
7061 INFO: Processing pre-safe import module hook   urllib3.packages.six.moves
8984 INFO: Loading module hooks...
8985 INFO: Loading module hook "hook-encodings.py"...
9069 INFO: Loading module hook "hook-pydoc.py"...
9075 INFO: Loading module hook "hook-selenium.py"...
9088 INFO: Loading module hook "hook-xml.dom.domreg.py"...
9094 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
9099 INFO: Loading module hook "hook-xml.py"...
9132 INFO: Looking for ctypes DLLs
9140 INFO: Analyzing run-time hooks ...
9148 INFO: Looking for dynamic libraries
9226 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_ssl.pyd
9296 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_ssl.pyd
9366 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_ssl.pyd
9445 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\unicodedata.pyd
9517 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\unicodedata.pyd
9586 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\unicodedata.pyd
9661 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\pyexpat.pyd
9725 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\pyexpat.pyd
9789 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\pyexpat.pyd
9856 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\pyexpat.pyd
9920 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\pyexpat.pyd
9996 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_hashlib.pyd
10068 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_bz2.pyd
10132 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_bz2.pyd
10196 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_bz2.pyd
10261 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_bz2.pyd
10327 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_bz2.pyd
10396 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_lzma.pyd
10465 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_lzma.pyd
10535 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_socket.pyd
10599 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_socket.pyd
10673 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\select.pyd
10746 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_elementtree.pyd
10812 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_elementtree.pyd
10883 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_elementtree.pyd
10947 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_elementtree.pyd
11013 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_elementtree.pyd
11098 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\lib\site-packages\win32\win32wnet.pyd
11166 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\lib\site-packages\win32\win32wnet.pyd
11234 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\lib\site-packages\win32\win32wnet.pyd
11311 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_ctypes.pyd
11377 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_ctypes.pyd
11441 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_ctypes.pyd
11512 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\_queue.pyd
11596 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libssl-1_1-x64.dll
11662 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libssl-1_1-x64.dll
11729 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libssl-1_1-x64.dll
11797 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libssl-1_1-x64.dll
12622 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libcrypto-1_1-x64.dll
12704 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libcrypto-1_1-x64.dll
12775 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libcrypto-1_1-x64.dll
12844 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libcrypto-1_1-x64.dll
12916 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libcrypto-1_1-x64.dll
12981 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libcrypto-1_1-x64.dll
13046 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libcrypto-1_1-x64.dll
13115 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libcrypto-1_1-x64.dll
13184 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\DLLs\libcrypto-1_1-x64.dll
13274 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\lib\site-packages\pywin32_system32\pywintypes37.dll
13348 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\lib\site-packages\pywin32_system32\pywintypes37.dll
13417 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\lib\site-packages\pywin32_system32\pywintypes37.dll
13485 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\lib\site-packages\pywin32_system32\pywintypes37.dll
13551 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\jack wong\appdata\local\programs\python\python37\lib\site-packages\pywin32_system32\pywintypes37.dll
13552 INFO: Looking for eggs
13553 INFO: Using Python library c:\users\jack wong\appdata\local\programs\python\python37\python37.dll
13554 INFO: Found binding redirects:
[]
13565 INFO: Warnings written to C:\Users\Jack Wong\Desktop\Python\build\pbb\warn-pbb.txt
13623 INFO: Graph cross-reference written to C:\Users\Jack Wong\Desktop\Python\build\pbb\xref-pbb.html
13681 INFO: checking PYZ
13681 INFO: Building PYZ because PYZ-00.toc is non existent
13682 INFO: Building PYZ (ZlibArchive) C:\Users\Jack Wong\Desktop\Python\build\pbb\PYZ-00.pyz
14323 INFO: Building PYZ (ZlibArchive) C:\Users\Jack Wong\Desktop\Python\build\pbb\PYZ-00.pyz completed successfully.
14345 INFO: checking PKG
14345 INFO: Building PKG because PKG-00.toc is non existent
14347 INFO: Building PKG (CArchive) PKG-00.pkg
16368 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
16377 INFO: Bootloader c:\users\jack wong\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
16377 INFO: checking EXE
16378 INFO: Building EXE because EXE-00.toc is non existent
16379 INFO: Building EXE from EXE-00.toc
16381 INFO: Appending archive to EXE C:\Users\Jack Wong\Desktop\Python\dist\pbb.exe
17387 INFO: Building EXE from EXE-00.toc completed successfully.

C:\Users\Jack Wong\Desktop\Python>pbb - hold
Then I go into the dist/pbb.exe and execute it. It said "Failed to execute script pbb"
my import of library would be like this
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
import xlrd



RE: Convert my .py to .exe but failed to execute - metulburr - Feb-18-2019

Ive never built an exe using selenium so i am not sure of the possible errors that could occur from it. It seems like every library added causes specific problems with building an exe related to that library.

try building the exe without the -w flag and run it from a terminal and see if you get an error and what that might be.

You can also try to use a spec file to see if the problem is related to chromedriver or not. I doubt it, but you never know.
.....
a = Analysis(['myscript.py'],
             pathex=['path\\to\\my\\script'],
             binaries=[ ('path\\to\\my\\chromedriver.exe', '.\\selenium\\webdriver') ],
             datas=None,
....
pyinstaller myscript.spec myscript.py



RE: Convert my .py to .exe but failed to execute - snippsat - Feb-18-2019

You should post the whole code,when having modules like selenium, xlrd there is outside dependencies(like web-driver) on OS.
It can be difficult to analyse error when making .exe and it fails.
I have done Selenium before with Pyinstaller,i think there where some step i had to do,don't remember as it's a long time ago.
Look at this post how i build and troubleshoot(with virtual environment) to get Pandas to work in one .exe file.

Basic test to make sure that pynstaller work.
# power.py
def power_of(arg):
   '''Calulate Powers of exponent(^) in python'''
   return arg ** arg

if __name__ == '__main__':
   user_input = int(input('Enter number to perform power of exponent: '))
   print(power_of(user_input))
   input('Press <Enter> to exit')
The build for this will be one file and it's console app.
pyinstaller --onefile --console power.py
The whole run,with some explanations



RE: Convert my .py to .exe but failed to execute - gahhon - Feb-19-2019

Hi. I found the root cause already.
This is the the .exe file is inside the dist folder, but my excel file is outside of it.
That's why it got execution error.

Thanks for the help :D


RE: Convert my .py to .exe but failed to execute - metulburr - Feb-19-2019

thanks for letting us know the issue, so others that have the same problem can come back to it and fix it.