5

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:

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
  • 1,389
  • 3
  • 13
  • 34

3 Answers3

5

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

Ravi Kumar
  • 772
  • 7
  • 8
4

I would suggest pyinstaller see http://www.pyinstaller.org/

The pyinstaller already supports 3.5

The development version supports 3.6

milo
  • 1,747
  • 9
  • 10
  • unfortunately, 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 do `python -m pyinstaller toto.py` I get an error message ‘no module pyinstaller’. – Stéphane Jun 26 '17 at 10:16
  • strange, Have you activated your environment? I mean first activate your environment and then install pyinstaller, after that use it – milo Jun 26 '17 at 12:40
  • after 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' – Stéphane Jun 26 '17 at 12:54
  • Have 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 Jun 26 '17 at 13:00
  • I 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 – milo Jun 26 '17 at 13:03
  • pyinstaller 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 ? – Stéphane Jun 26 '17 at 13:45
  • It 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 – milo Jun 26 '17 at 14:32
  • yes 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 – Stéphane Jun 26 '17 at 15:14
  • 1
    So maybe try to google pyinstaller pyqtgraph together, there could be some solution about it – milo Jun 26 '17 at 15:26
0

It is better to use spec file to import other hidden libraries. I listed all Sklearn libraries and add them to spec file as a hiddenimports, you can add libraries you used in your project.

Ahad aghapour
  • 2,453
  • 1
  • 24
  • 33