首页 > 解决方案 > Including a C++ executable when freezing a Python script with PyInstaller

问题描述

I've tried to read through the PyInstaller documentation and using spec files, as well as Google/SO, but haven't found any clear answers.

I have written a python script using Biopython, and have made it into an executable with PyInstaller and it works fine. However the script uses a Biopython function (NcbiBlastnCommandline()) that is a wrapper for the NCBI Blast+ blastn program (written in C++), and at the moment the user still needs to have the NCBI Blast+ installed locally.

Is it possible to package the C++ .exe along with the rest, so the end user only needs to download my executable and nothing else?

标签: c++executablebioinformaticsbiopythonblast

解决方案


Read the part of the tutorial about adding binary files:

To add binary files, make a list of tuples that describe the files needed. Assign the list of tuples to the binaries= argument of Analysis.

a = Analysis(...
     binaries=[ ( '/path/to/blastn.exe', 'blastn.exe' ) ],
     ...

推荐阅读