Pyinstaller | Extrected Exe unable to find sub module - python-2.7

I am new in Python. Currently Using Python 2.7. As a current exercise I am converting Python Script to exe file through PyInstaller. I am finding trouble in finding certain modules through generated exe which are working perfectly fine while I am running through Python Script.
I have created exe through --onefile option in PyInstaller. As a part of exercise I have already done the following points,
Verified that python file is exist at particular locaion(temp location) including python compiled file.
I updated sys.path entries to find python at particular(temp) location.
I also verified that imp.findModules able to find the module but imp.loadModule failed to load the module while running through exe file.
Note that while I am running the python file from command line it works fine, it only gives error while I am creating exe file.
Problem Image is attached here.
Any help would be appreciated.
Regards,
Sunay Shah

I have seen that many people are facing the issue. I fixed the Issue and following is the solution for the same.
During packaging with the help of PyInstaller , I found out that PyInstaller is analyzing the given python file and imports packages itself which it found during the analysis phase. Those which packages which are found and would be zipped during the packaging can be seen in the build folder created by PyInstaller (out00-Analysis.toc,out00-PKG.toc,out00-PYZ.toc,out01-Tree.toc,warnXXX.txt file ) are the important files to look into.
During my problem analysis I found that my certain packages are not imported during the Analysis phase. I came to know on digging that we need to include those packages in data files. So I copied almost all my packages that are required into data section in .spec file. Still problem continues. I dig little more and found that although artifacts are packaged they are unable to import during execution.
I gone through some in more details and found out that issue was around that during runtime certain modules were not able to import by PyInstaller. I found that issue can be resolved with the help of hidden-imports. I added missing modules in hidden-import section which resolved the issue.
Making Long story short , following are the key take away from my problem
1. Create a Build with default option , resolve all your problems
2. Include all the required modules into the build with datas section which were not found out by PyInstaller.
3. Add hidden imports which were not imported by Pyinstaller. ( e.g if abc.contrib.usages module is not loaded during runtime, add that into hiddeniports sectin.
4. Once created exe works with default option use --onefile to create the build.
5. Best way to resolve your problems is analyze all the files created in build folder during the creation of the build.
Hope this will help some one to fix there issues.
Regards,
Sunay Shah

Related

Running my GIS application using dev-c++ gives "gdal201.dll is missing"

I'm working on a GIS application in C++ using Dev-C++, and to start for now I'm using the code given in the tutorial in Link
I got it to compile without errors or warnings, but when I try to run it I get the error "The program can't start because gdal201.dll is missing from your computer. Try reinstalling the program to fix this problem."
I was looking at another question with the similar problem and tried to search this dll on internet, but couldn't find it anywhere, and somebody mentioned to ignore the error, but I don't know how to do that.
Can anybody help me on what to do here?
Thanks in advance.
You need the DLL file(s) to be present either in the same directory as the executable, or in your Path variable for the system to be able to find them. I personally prefer setting Path. You might consider either adding GDAL_DIR\bin to your permanent Path by editing system or user environment variables, or else create a small batch file on the desktop which adds the directory to Path then starts devenv.exe if you need to manage several incompatible development environments for different projects.
(This has several advantages in my experience over copying the DLL files to the same directory as the executable: It's easier to manage dependencies by including all the necessary directories, as opposed to manually tracking down all the recursive dependencies. It's also easier to manage updates of the DLLs if you can just update the GDAL installation directory, or update Path or the batch file to a newer GDAL installation directory, rather than having to track down all the places you've copied the DLLs to or having to manage post-build scripts to copy the DLLs every time.)
(Of course, when it comes time to create a self-contained installer, it's going to be easiest to copy the dependent DLLs to the installer image directory before building the installer. Then something like CMake's BundleUtilities module can help in tracking down what DLLs need to be included.)
Usually I copy private DLLs to the output folder of the project, i.e. the same folder as the executable. For a commercial application, you may want to install the DLL, let the OS handle the management of it and use the Assemblies Manifest to help the loader find it.

Error running "pbiviz start" in new project folder

This appears to be the same issue another person posted earlier today (Could not connect Custom Visual server in powerBI) but I can supply additional information applicable in my own environment.
There is one answer recommending building the simple bar chart example, but I understand that the sample visual.ts that was created by the "new" command should build.
I am running the command from within the project folder where the pbiviz.json file was created with the "new" command.
Here is an image showing a directory listing for the folder as well as the output for the operation. What I see is that the initial error line is looking for a folder path starting directly under the project folder with "node_modules" -- and that is not there at all.
So, am I running into a problem with the version something or do I need to install something additional, or ???
I had been following the steps from the Readme.md documentation at Microsoft/PowerBI-visuals folder on github and have had no errors until this one.
Try type in your directory: npm install, and then pbiviz start.

Editing a pyinstaller .exe file

So, i have managed to create an executable file in windows, out of a python script using pyinstaller. I tried pyinstaller myscript.py and the buid and dist folders were created, along with the .spec file
However, at a later time, i am making changes to the underlying code. So what i need to do is recompile and my application works again.
But, is there a way in which i can edit the already existing application? Or do i have to always recompile, after making a change ?
Also, what is the purpose of the .spec file?
Spec-file is needed to keep some options for pyinstaller to build your project such as hidden imports, attached data files, the name of output exe-file, etc. It is always created by using pyinstaller first time. Next time if you want to build your changed project use this command specifying the spec-file:
$ pyinstaller myscript.spec
For more information about spec-files read documentation: https://pyinstaller.readthedocs.io/en/stable/spec-files.html

Python project to exe

I've been working on a rather large Python project containing both downloaded packages (xlwt, xlrd etc. ) and user defined packages and I'd like to pack it into a single .exe file. I've been searching, but can't seem to find something on how to make an executable from such a project.
Any thoughts or links that might help?
EDIT: I've looked into Py2exe, cx_freeze etc. problem is that I can't find a description on how to make an exe file for a project with multiple user defined packages.
There are a few projects that might interest you:
CX Freeze
py2exe
pyinstaller
bbfreeze
These essentially "freeze" your code ship it with a bundled Python interpreter.
There is py2exe extension that creates *.exe file for your Python application. See http://www.py2exe.org/ (and more specifically, http://www.py2exe.org/index.cgi/Tutorial).

QtCreator No Executable Specified

I've searched this for a while and haven't found anything answered anywhere:
I have a project in QtCreator that has no compilation errors, and runs fine as a normal C++ project in Eclipse.
However, when I try to run it as a Qt app, it says it could not find an executable and I need to specify one.
As many other sites have suggested, I have searched the directories for the .exe that QtCreator was supposed to make (according to the other sites), but I am yet to find anything.
I'm in no rush, but have spent a long time on this and would like to move on to actually writing the Qt part.
Thanks in advance.
Are you still struggling with the solution ? The most easy solution is, restore default setting by deleting file QtCreator.ini. After that configure project once again by giving build directory path. If you are working on Linux system, run following command to find QtCreator.ini file.
$ locate QtCreator.ini
It will give ouput like this
/home/tan/.config/QtProject/QtCreator.ini
Then delete the file on obtained path using following command
$ sudo rm -f /home/tan/.config/QtProject/QtCreator.ini
Now open project once again and configure with your desired build and run settings.
Upvote if above solution helps you. Btw if I've made any grammatical mistakes, I am sorry for my english. :)
Best luck !!
I'm not sure I understand what you mean by having a QtCreator project and running it in Eclipse or running it as a Qt App but if you are looking for an exe file, QtCreator is probably configured to do shadow builds for your project. This means that build output is sent to a directory outside of your project source directory. If your project is in a directory called MyApp, then look for a directory beside it called MyApp-build-desktop. You should find your executable in there.