last day (14 days later) » 

17:39
0
Q: How to use pyinstaller or cx_freeze to package a python script containing traitsui, tensorflow and matplotlib?

taigi100I'm looking for a way to distribute the following code, to a Windows 10 machine: """ Neural Network with Eager API. A 2-Hidden Layers Fully Connected Neural Network (a.k.a Multilayer Perceptron) implementation with TensorFlow's Eager API. This example is using the MNIST database of handwritten ...

Note that a StackOverflow question should include everything needed to answer inside the question itself, so it's still meaningful even if external links break or change. Links can be welcome, but only if the question is still complete and answerable without them. When adding code to the question itself, use the {} button in the editing UI to format it.
@CharlesDuffy There you go, I've edited the question. Yes, I've reviewed that question a few times now. Keep in mind, that's for Pyinstaller and I get that error on cx_freeze. The error I get with pyinstaller is totally different.
Thank you -- the added content is helpful. (Ideally we'd have a Minimal, Complete, and Verifiable example -- the shortest possible runnable code that causes the same error -- but this is good enough). This generally means that there's a runtime import that pyinstaller isn't discovering -- if you can track down what it is, you can manually add an explicit import or a hook for it.
Note that pyface.ui.null is actually a package that really exists. Adding an explicit import for it and then rebuilding your package with pyinstaller may be all you need.
...that said, the traitsui docs specify very explicitly that it does require one of four possible UI toolkits (PyQt, wxPython, PySide, or PyQt5) to work correctly. Figuring out which one you intend to use and adding an explicit import for it would also be a step in the right direction.
@CharlesDuffy Updated the question with the results from explicitly importing them and setting the a backend (Honestly, don't really care which UI toolkit I'm going to use, I simply want to manage to build it)
You also need an explicit import traitsui.toolkits.qt4. Basically, pyinstaller needs to be able to find all the imports you need without relying on any dynamic behavior (so calls to __import__() or imp.find_module() need to be supplemented with actual import statements with concrete arguments).
...to be clear, btw, the extent that you don't care about the how is part of why I'm commenting and not answering (the other extent is related to the question's breadth -- if it were narrowed to a MCVE and a specific problem, one could have a complete, canonical and tested answer, but here you've got a bunch of distinct libraries mixed with a bunch of your own code). I actually think this question is too broad to be within SO's topic guidelines, but you're making a good-faith effort, so I'm trying to help to some extent regardless, hence the back-and-forth in the comments here.
...our goal is to be a Q&A database, not a source of general debugging assistance except to the extent that said assistance can be distilled down to simple, unique questions with canonical answers that are likely to help other people. "Why do I get an error about pyface.ui.null when trying to use pyinstaller to bundle traitsui?" would be a great question, for example, coupled with the shortest code that generates that error in question. You've similarly got several different potential cx_Freeze minimal questions; asking them as one big block makes it impossible to write a canonical answer.
17:39
@CharlesDuffy Updated the question accordingly. Also tried a few more ways which didn't work. Sorry for the not well though through the question - It's my first python project, the initial agreement wasn't to make it a .exe and now they want a .exe asap. It's a little bit frustrating that packaging this takes over double the time of the entire project itself.
nod -- I've been through similar pain. Ended up with pyinstaller after several other tools, but even then, nothing's completely free. So, high-level, since I can't test anything atm -- basically you want to keep continuing on the approach you've currently got going; identify imports that happen at runtime and make them explicit, rinse, repeat, etc.
("atm" because I'm on day job hours)
Re: the DLL warnings, if they happen at build time you might not need to worry about them (assuming your application works in the build environment, and those DLLs are genuinely not present there); it's DLLs whose nonpresence is fatal at runtime because pyinstaller failed to locate and bundle them that we need to worry about.
...there are exceptions/caveats, but it's all case-by-case, annoyingly. Which is to say, yes, this really is a timesink.
Any clue if I should focus on getting it working with qt4 (which seems default) or try to get it working with qt5?
 
2 hours later…
19:30
I'd try to figure out which one is installed on your build system, and stick with that.
whatever it's already using when you run your code with a regular Python runtime is going to be the toolkit that has dependencies present, so you just need to tell pyinstaller about them, vs needing to install extra bits as would be the case if trying to get it to use something else.

last day (14 days later) »