Posts: 46
Threads: 14
Joined: Jan 2019
Feb-27-2019, 12:44 PM
(This post was last modified: Feb-27-2019, 12:44 PM by gahhon.)
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
Posts: 7,313
Threads: 123
Joined: Sep 2016
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.
Posts: 46
Threads: 14
Joined: Jan 2019
(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.
Posts: 7,313
Threads: 123
Joined: Sep 2016
Feb-27-2019, 04:47 PM
(This post was last modified: Feb-27-2019, 04:48 PM by snippsat.)
(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.
Posts: 46
Threads: 14
Joined: Jan 2019
(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?
Posts: 7,313
Threads: 123
Joined: Sep 2016
Feb-27-2019, 06:05 PM
(This post was last modified: Feb-27-2019, 06:06 PM by snippsat.)
(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
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.
Posts: 46
Threads: 14
Joined: Jan 2019
(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
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.
Posts: 7,313
Threads: 123
Joined: Sep 2016
Feb-27-2019, 08:49 PM
(This post was last modified: Feb-27-2019, 08:49 PM by snippsat.)
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.
Posts: 46
Threads: 14
Joined: Jan 2019
(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.
Posts: 46
Threads: 14
Joined: Jan 2019
(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?
|