0

I'm a data engineer. Now I've developed a Python program and need to build it into a Linux binary. What do I do?

Redish101
  • 1
  • 1
  • 2
    You can’t *really* do that, nor do you generally *need* to. At best you can use a wrapper binary that bundles your code, but (especially on Linux) this is very rarely necessary. Usually you’d distribute the scripts via an installer. — What’s your use-case? – Konrad Rudolph Dec 14 '21 at 11:36
  • As a data engineer using Linux and Python every day, I would need to know more about your use case to understand why it is necessary? You can execute python code from the linux terminal by using "python python_file_name.py" and execute linux code from Python e. g. by using "os.system(linux_command)". – It works on my pc Dec 14 '21 at 11:41
  • 1 option is to freeze the code to an executable using [pyinstaller](https://www.pyinstaller.org/). second options is relevant in case your script serves as a module (or a package), than you can [package](https://packaging.python.org/en/latest/tutorials/packaging-projects/) it – jsofri Dec 14 '21 at 11:48
  • A couple of years ago I have created a .exe (on Windows) from a python program. I think that it also works on linux. I used the answer from Maria Irudaya Regilan J on [this](https://stackoverflow.com/questions/41570359/how-can-i-convert-a-py-to-exe-for-python) post. – suitendaal Dec 14 '21 at 13:33

1 Answers1

0

if you need to make a executable file you can use

pip install pyinstaller

to install a installer And then uses this command for make a executable file :

pyinstaller yourprogram.py

and please read this post How to Run an executable file on Raspberry pi

  • 1
    You should mention that the binary in the case of pyinstaller still includes the source code — it doesn’t actually compile the Python code, it just bundles it with a minimal Python installation. – Konrad Rudolph Dec 14 '21 at 11:59