Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 py2exe failed to compiled
#1
I am using Python 3.7.2 and py2exe 0.9.2.2
I have followed the tutorial from Py2exe Tutorial
But I am still failed to convert the script into executable file as I can't find any right solution through google search.

Log:
C:\Users\Jack Wong\Desktop\PythonTutorial>python setup.py py2exe
running py2exe
Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    setup(console=['google.py'])
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
    self._run()
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
    builder.analyze()
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\runtime.py", line 160, in analyze
    self.mf.import_hook(modname)
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
    module = self._gcd_import(name)
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
    return self._find_and_load(name)
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
    self._scan_code(module.__code__, module)
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 388, in _scan_code
    for what, args in self._scan_opcodes(code):
  File "C:\Users\Jack Wong\AppData\Local\Programs\Python\Python37\lib\site-packages\py2exe\mf3.py", line 417, in _scan_opcodes
    yield "store", (names[oparg],)
IndexError: tuple index out of range
setup.py
from distutils.core import setup
import py2exe

setup(console=['google.py'])
Previously I am used the pyinstaller to convert and it successful to execute the .exe file in my machine.
But failed to execute the .exe file to other machine that don't have Python installed.
After I searched, I found out that py2exe approach is able to execute the .exe file in Non-Python machine.

Please kindly advise.Thanks
Quote
#2
Py2exe stopped develop at Python 3.4 and do not work for newer versions.
Use pyinstaller work Python 3.7.
Look at posts in this Thread and my run in this post.
Quote
#3
(Feb-27-2019, 01:28 PM)snippsat Wrote: Py2exe stopped develop at Python 3.4 and do not work for newer versions.
Use pyinstaller work Python 3.7.
Look at posts in this Thread and my run in this post.

But if convert to .exe by using pyinstaller, the client computers are not able to execute the .exe files due to their computers have no Python installed.
That's why I am consider to using the py2exe.
But do you have any advises what should I do with pyinstaller, so that my client computers can execute the .exe files without needed to install Python in their computer?
Thanks for advance.
Quote
#4
(Feb-27-2019, 03:44 PM)gahhon Wrote: But if convert to .exe by using pyinstaller, the client computers are not able to execute the .exe files due to their computers have no Python installed.
That's why I am consider to using the py2exe.
Then you doing something wrong,like not aware that stuff can be outside(Python) link to OS that's need to be included.

Follow all in this post.
So if move power.exe to Pc without Python then it will work.
power.py is simple file with no external dependencies.

Look at Sound-player standalone,
see that i take step to include external OS dependencies AVbin avbin.dll(windows) and libavbin.so.10(Linux).
If i do not do this,it's not a standalone solution.
See also that i start with virtual environment,to have isolation from OS in first place before start troubleshoot.

Have to understand that there never will be one easy solution for doing building stuff like this.
py2exe had of course the same problem,if there where external dependencies.
Quote
#5
(Feb-27-2019, 04:47 PM)snippsat Wrote:
(Feb-27-2019, 03:44 PM)gahhon Wrote: But if convert to .exe by using pyinstaller, the client computers are not able to execute the .exe files due to their computers have no Python installed.
That's why I am consider to using the py2exe.
Then you doing something wrong,like not aware that stuff can be outside(Python) link to OS that's need to be included.

Follow all in this post.
So if move power.exe to Pc without Python then it will work.
power.py is simple file with no external dependencies.

Look at Sound-player standalone,
see that i take step to include external OS dependencies AVbin avbin.dll(windows) and libavbin.so.10(Linux).
If i do not do this,it's not a standalone solution.
See also that i start with virtual environment,to have isolation from OS in first place before start troubleshoot.

Have to understand that there never will be one easy solution for doing building stuff like this.
py2exe had of course the same problem,if there where external dependencies.

I think I know the clue already.
I have to install the pipenv.
Then using the pipenv to install pyinstaller, selenium, and any other libraries that I had import in my script.
Then in my script, I must add the pyglet.lib.load_library('avbin.dll') pyglet.have_avbin=True
But in your post, you were mentioned that pyglet & avbin is for the playing. But what if for Selenium?
Quote
#6
(Feb-27-2019, 05:45 PM)gahhon Wrote: Then in my script, I must add the pyglet.lib.load_library('avbin.dll') pyglet.have_avbin=True
But in your post, you were mentioned that pyglet & avbin is for the playing. But what if for Selenium?
Do you not understand that this a example of including external dependencies and has nothing to with your build.
You should of course not add pyglet & avbin in your build,why do i even need to explain this Dodgy

Selenium has at least one external dependencies which is the web-driver,
so a simple solution could eg to have chromedriver.exe together with the build .exe.
I have build Selenium with pyinstaller before(working),but it's long time ago so don't remember all the build steps.
Quote
#7
(Feb-27-2019, 06:05 PM)snippsat Wrote:
(Feb-27-2019, 05:45 PM)gahhon Wrote: Then in my script, I must add the pyglet.lib.load_library('avbin.dll') pyglet.have_avbin=True
But in your post, you were mentioned that pyglet & avbin is for the playing. But what if for Selenium?
Do you not understand that this a example of including external dependencies and has nothing to with your build.
You should of course not add pyglet & avbin in your build,why do i even need to explain this Dodgy

Selenium has at least one external dependencies which is the web-driver,
so a simple solution could eg to have chromedriver.exe together with the build .exe.
I have build Selenium with pyinstaller before(working),but it's long time ago so don't remember all the build steps.

Yes. I did put the chromedriver.exe together with my build.exe and test it on NON-Python machine, but the error is saying
Error loading Python DLL
'.....\python37.dll'
LoadLibrary: Pyinstaller: FormatMessagW Failed.

And I also found this Create a Python executable with chromedriver & Selenium
Will give it a shot by tomorrow.
Quote
#8
A quick test,an you have to read the doc.
So can use spec file that get create every time run pyinstaller or add stuff with commands.
Adding binary from commands.
pyinstaller --onefile --console --add-binary chromedriver.exe;. duck_go.py 
In spec file it look like this '.' or command line ;. means find file in folder you run from an add it to build.
binaries=[('chromedriver.exe', '.')],
So when i build i have chromedriver.exe is same folder as .py file,and no path giver to chromedriver.exe in .py file.
browser = webdriver.Chrome(executable_path=r'chromedriver.exe')
If move .exe to other Pc it work when in this test.
Quote
#9
(Feb-27-2019, 08:49 PM)snippsat Wrote: A quick test,an you have to read the doc.
So can use spec file that get create every time run pyinstaller or add stuff with commands.
Adding binary from commands.
pyinstaller --onefile --console --add-binary chromedriver.exe;. duck_go.py 
In spec file it look like this '.' or command line ;. means find file in folder you run from an add it to build.
binaries=[('chromedriver.exe', '.')],
So when i build i have chromedriver.exe is same folder as .py file,and no path giver to chromedriver.exe in .py file.
browser = webdriver.Chrome(executable_path=r'chromedriver.exe')
If move .exe to other Pc it work when in this test.

I am trying. Will let you know soonly.
Quote
#10
(Feb-27-2019, 08:49 PM)snippsat Wrote: A quick test,an you have to read the doc.
So can use spec file that get create every time run pyinstaller or add stuff with commands.
Adding binary from commands.
pyinstaller --onefile --console --add-binary chromedriver.exe;. duck_go.py 
In spec file it look like this '.' or command line ;. means find file in folder you run from an add it to build.
binaries=[('chromedriver.exe', '.')],
So when i build i have chromedriver.exe is same folder as .py file,and no path giver to chromedriver.exe in .py file.
browser = webdriver.Chrome(executable_path=r'chromedriver.exe')
If move .exe to other Pc it work when in this test.

Okay. It appear that the chrome browser is launched, but I got the log error saying that IndexError: ('list index out of range',)
This error doesn't appear in my local, but in my client computer.
Any idea tho?
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Pyinstaller with Sys.Argv[] - “Failed to Execute Script”? ironfelix717 0 106 Aug-07-2019, 02:29 PM
Last Post: ironfelix717
  Help with PyInstaller + Script "Failed to Execute Script" ironfelix717 2 150 Jul-31-2019, 02:18 PM
Last Post: ironfelix717
  Setup failed 0x80070005 Santo 9 10,782 Jun-10-2019, 05:20 PM
Last Post: Nikmartin
  MySQL executemany - Failed executing the operation; Could not process parameters josh_marchant 1 289 May-16-2019, 04:22 PM
Last Post: woooee
  Failed Install NetfilterQueue Alamily 2 1,022 Mar-09-2019, 02:36 PM
Last Post: Alamily
  pip3 install functools failed kintarowonders 1 646 Mar-07-2019, 07:56 PM
Last Post: nilamo
  Hello Im looking for a compiled window version of 3.4.x ... SlowMotion 2 241 Feb-12-2019, 08:13 PM
Last Post: SlowMotion
  What are ways of pointing cross-compiled origin source line for python? wyvogew 2 302 Feb-02-2019, 03:16 PM
Last Post: wyvogew
  error: (-215:Assertion failed) gkiller007 1 1,911 Jan-04-2019, 04:27 AM
Last Post: stullis
  py2exe keegan_010 4 848 Aug-22-2018, 07:58 AM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)