0

I'm working on project where I am using Python/C API and C++. C++ is used for most part of application, mainly for gui (wxWidgets), while Python is used for calculations on large data sets, e.g. from files. I'm doing it in Visual Studio and when I run the project in IDE everything works fine, like I want it to. Also, the exe file that is created during the launch of the project in the visual studio, when it is in the same folder with the python .py file, also works as it should be. But what I want to achieve is a complete application contained in one exe.

While searching for a solution, I found various possibilities to create an exe from a python file. For example, PyInstaller which I tested for a simple "hello world" python file and it works. However, I don't know and can't find a solution how to combine the exe created in visual with a python file.

In PyInstaller github issues I found that line:

pyinstaller App.py --add-data 'pathtoexe\your.exe;.' --add-binary "pathtodll\your.dll;." --onefile --noconsole --clean

And I typed this into the console:

pyinstaller myPythonFile.py --add-data 'myVisualGeneratedFile.exe;.' --onefile --noconsole --clean

But after that, when I clicked generated exe file, nothing happens.

I hope that someone has done a similar thing before and I can find help here because I'm already losing my mind on it.

  • why not use wxPython for your GUI? Then no C++ executable will be involved. And there will be easy enough conversion. – Igor Jul 21 '20 at 19:17
  • My program is almost complete. So I have to say that I would not like to rebuild the entire application to use wxPython. Unfortunately, I have not checked it earlier, but if someone could help, I would prefer to stay with the current system. – MikeTrusky Jul 21 '20 at 21:59

1 Answers1

0

According to https://pyinstaller.readthedocs.io/en/stable/usage.html, you should use --add-binary and not --add-data.

Igor
  • 5,620
  • 11
  • 51
  • 103
  • Unfortunately, it did not help. What I checked was: `pyinstaller myPythonFile.py --add-binary 'myVisualGeneratedFile.exe;.' --onefile --clean` But the same, click exe file and nothing happens. I wonder what the .spec file should look like. Maybe I should add some extra lib files. But I don't know which files. – MikeTrusky Jul 22 '20 at 13:36
  • @MikeTusky, are you using static or DLL build of wx? if the latter - you should also add all wx libraries the binary depends on... – Igor Jul 22 '20 at 15:42
  • I think I have static build, only .lib files. And now I'm trying to simplify it and I created simple c++ file, which only print out some word, then execute python file(print hello world) and in the end print out again some word. And after I get exe file from visual, I tried again "pyinstaller ..." command. What I achieved is one single exe which give me "hello world" after clicked on it. It looks like it completly ignore exe with c++ code. – MikeTrusky Jul 22 '20 at 16:59