how to build .exe for python 3.5+, 3.6 if possible?
Solution 1
Pyinstaller Works with Python 3.5 and it is working even for packages like tensor-flow, scipy , etc (The packages I worked with)
py -3.5 pip install pyinstaller
then go the C:\Users\user\AppData\Local\Programs\Python\Python35\Scripts and run the command
pyinstaller <code .py file along with directory> --onefile
--onefile : is for compressing the build and get a single file as output
Solution 2
I would suggest pyinstaller see http://www.pyinstaller.org/
The pyinstaller already supports 3.5
The development version supports 3.6
Comments
-
Stéphane almost 2 years
Is there now an easy protocol to build a .exe from python 3.5+, using modules pyqtgraph, qt5, theano, pymc3, numpy, scipy, os and sys, and opening a simple GUI stored in a '.ui' file ? I lost hours and eventually failed to make one (for w7-64 bits). Help !
preliminary failure with py2exe: I first install py2exe for python 3 but it turns out this is not compatible with my python 3.6 yet, so I downgraded to python 3.5… to get a bunch of errors. Then I went to forums and tried the proposed cures but failed (I’m uneasy with windows), the alternative being to downgrade to python 3.4… So I downgraded to python 3.4 to get an error concerning a missing ‘msvcr100.dll’ that I tried to install following instructions on forums but by default I don’t have the permission to modify system directories… When I eventually had this permission it turns out the ‘regsvr32’ command fails (isn’t this for 32 bits ? but there is no ‘regsvr64’…). Following episodes are described below.
update august 23, 2017, 1pm:
I also tried pyinstaller as advised but it failed (see my related question build a .exe for Windows from a python 3 script importing theano with pyinstaller)
I also tried cx_freeze but it failed (see my related question build a .exe for Windows from a python 3 script)
I also tried pynsist but it fails (same link than above)
what's next ?
update september, 2, 2pm:
I eventually managed to build a .exe with pyinstaller after many episodes.
Unfortunately I failed to deal with the ‘theano’ module (that is required in my case by the ‘pymc3’ module) and I had to modify the .py files and give up part of the application. Could anyone help me building a .exe for windows 7+, with the ‘theano’ module ?
see build a .exe for Windows from a python 3 script importing theano with pyinstaller
-
Stéphane almost 7 yearsunfortunately, I wasn’t able to use pyinstaller: I installed a virtual environment with python 3.5 and pyinstaller. Once in this environment, if I do
pyinstaller toto.py
it keeps on taking python 3.6 (and thus fails), if I dopython -m pyinstaller toto.py
I get an error message ‘no module pyinstaller’. -
milo almost 7 yearsstrange, Have you activated your environment? I mean first activate your environment and then install pyinstaller, after that use it
-
Stéphane almost 7 yearsafter re-re-reactivating the python 3.5 env and restarting Windows,
pyinstaller toto.py
seems to take python 3.5... but stops after a 100s lines of errors finishing with '...yield inside async function'... I did not even use the command 'yield' in 'toto.py' -
milo almost 7 yearsHave a look at the doc of pyinstaller, There are lots of detailed information to deal with errors. Pyinstaller is a out of box tool but still need some necessary configuration.
-
milo almost 7 yearsI would suggest to write a simplest python module(print hello world in in a main function) and convert it to a exe by pyinstaller to know how pyinstaller works
-
Stéphane almost 7 yearspyinstaller recommends using ‘virtualenv’ to manage environments. From what I suspect, it doesn’t like environments managed by anaconda. So I installed virtualenv… the simple ‘hello world' script works… but not my program: sill this ‘yield’ message. It is a GUI using pyqtgraph. Does it matter ?
-
milo almost 7 yearsIt could matter, pyinstaller uses a hook system to deal with 3rd party libs. You may have a look at the hook of your lib in pyinstaller. You can always try to use hiddenimports to import all module of you lib and codes at first
-
Stéphane almost 7 yearsyes it's definitely a pb with pyqtgraph: when I add
import pyqtgraph
to the 'hello world' test, it fails. but the option '--hidden-import' doesn't change anything:pyinstaller test.py --hidden-import pyqtgraph
also fails -
milo almost 7 yearsSo maybe try to google pyinstaller pyqtgraph together, there could be some solution about it