Editing a pyinstaller .exe file - python-2.7

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

Related

How to recompile a single .cc file in a project built previously with CMake tool in Ubuntu 20.04?

I am using the ORB_SLAM3 project (https://github.com/UZ-SLAMLab/ORB_SLAM3) as a baseline for a monocular odometry system.
To understand how the ORB_SLAM3 software ingests the EuRoCV dataset, I am modifying some of the initial codes in the mono_euroc.cc file available in /Examples/Monocular folder.
However, each time I change the .cc file, I cannot compile just the mono_euroc.cc file by itself, but need to run the ./build.sh command from the parent directory which executes the entire CMake. The process which takes a while to complete.
My question is, is there a tool within CMake that would allow me to only change the "mono_euroc.cc" file directly from the "/Examples/Monocular" subdirectory rather than having to constantly invoke the "./build.sh" from the parent directory?
For the time being, I am following this process. I opened two terminal windows, both pointing to the parent directory (i.e ~/Dev/ORB_SLAM3). Everytime I change something in the target file (here it is the ./Examples/Monocular/euroc_mono) I execture the ./build.sh command in one and run the file on the other. I can confirm that though the cmake command looks over all the files, it only builds the one that was changed. I guess this method works when one is using the CMake tool to build a C++ project in Linux.

.exe not opening input file

I'm coding on CLion and made this log in function. The tests are being made through the .exe because CLion's Terminal sometimes jacks up the I/O's. The problem is my .exe is not finding the files I'm specifying. It runs properly through the CLion terminal, but when shifting to the .exe it doesn't.
I've read that putting those files in the cmake-build-debug/ directory fixes the issue - and it does. Thing is, this is a group project, and by putting those files in that directory I'll constantly run into compatibility troubles when pulling from git - .cmake-build-debug would have to be pushed, thus i'd have to reload it every time. This doesn't seem very proper to me.
The other option is to put the .exe file and required .dll's in the main directory. Again, would have to update this file every single time i build the project, which also isn't a very practical solution.
So I'm asking for some help regarding what can I do to ensure my .exe searches for files in the main directory, not just on the cmake-build-debug directory. The directories are included in CMakeLists, and the .exe still doesn't find them. This is quite the issue. The project will also include some rudimental form of database, so file handling will be important. Would be nice to be able to code and build without having to manually change stuff around every single time.

Change a default path in the Atom editor

I am using the Atom text editor to write c/c++ codes. By default I need to save all my programs in the C:>.atom> packages> MinGW> bin folder.
Now, I want to change the location where my programs are stored to a new folder which is comfortably placed in say, C:> My Programs. This works fine in CodeBlocks and before creating any console application there, I can choose the location manually and therefore all my programs are neatly arranged in the folder C:> My Programs that I have created. But, when I try to place a program anywhere other than the C:>.atom> packages> MinGW> bin folder or simply try to open a previously created program (with CodeBlocks) from the C:> My Programs folder, this error pops up in Atom -
'g++' could not be spawned. Is it installed and on your path? If so please open an issue on the package spawning process.
I don't know what to do.. How can I 'tell' the gcc compiler that look into this file rather than the default?
Can anyone please guide me through the steps?
Thank you so much.

How to run c++ program written in eclipse, from terminal

I'm using Ubuntu and I have written my c++ code in Eclipse Neon.
My workspace contain 4 projects. The main project is called BaseCppProjectRun (it contains main.cpp file) and I have other projects with these names: Encoders, frmwrk, NetworkLayer - the BaseCppProjectRun using each one of them.
If I running my program directly from eclipse everything works.
But I want to running my program from terminal - and I can't.
Because When I'm trying to run my progrm like this:
root#ubuntu:/builds/BaseCppProject/BaseCppProjectRun# ./Debug/BaseCppProjectRun
I'm getting this error:
./Debug/BaseCppProjectRun: error while loading shared libraries: libfrmwrk.so: cannot open shared object file: No such file or directory
As I said before, if I'm running it directly from eclipse everything works.
How can I run my program from terminal?
How is Linux supposed to know where to find libfrmwrk.so, if you don't put that either where it normally looks nor tell it where it can be found.
Eclipse seems to set up the paths the runtime linker looks into so, that when your program is loaded, the runtime linker knows where to find your libfrmwrk.so and so on.
You'll either have to
install these libraries (.so's) so that they are found in default locations, or
set LD_LIBRARY_PATH to contain all the folders to look into.
I haven't worked with Eclipse CDT in ages, but you can by now probably export some project formats that allow you to easily install things.
Another thing: It seems you're running software you're still debugging as root: That is a terrible idea, and if it can be avoided, avoid it.
I finally figure it out!
Refere to Marcus Muller's answer + my steps this is how I have fixed it ( all steps via terminal):
Create new directory in my workspace directory and called it libs.
In each one of your projects do: right click > c/C++ Build > Build Steps (tab) and in Post-build steps paste this:
cp ${BuildArtifactFilePrefix}${BuildArtifactFileName} "${WorkspaceDirPath}/libs/"
This code copy the so files directly into your libs directory when you compile your program.
And finally, in your terminal execute this:
export LD_LIBRARY_PATH=/builds/BaseCppProject/libs/
Now you can run your program via terminal.

Pyinstaller | Extrected Exe unable to find sub module

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