How can I get a binary from a .py file












4















I need a program to compile python source code; as I found out at first I need to make a binary file from my python script.



I've already checked a lot of links, but still I haven't found something for Linux.



I found py2bin for OS/X, but there are no versions for Linux.










share|improve this question

























  • Python 2 or Python 3? Also, is Nuitka or dis closer to what you want?

    – Nathaniel M. Beaver
    Feb 20 '18 at 13:11











  • Cython is a popular optimizing static compiler for Python.

    – fpmurphy
    Feb 20 '18 at 13:15











  • wiki.python.org/moin/Freeze That method will compile executables for *nix systems. Although I'm not sure if that's what you want.

    – alpha
    Feb 20 '18 at 13:17











  • disassembling python code?

    – Rui F Ribeiro
    Feb 20 '18 at 13:22













  • Unless you mean create "precompiled" python modules (.pyc)?

    – xenoid
    Feb 20 '18 at 13:34
















4















I need a program to compile python source code; as I found out at first I need to make a binary file from my python script.



I've already checked a lot of links, but still I haven't found something for Linux.



I found py2bin for OS/X, but there are no versions for Linux.










share|improve this question

























  • Python 2 or Python 3? Also, is Nuitka or dis closer to what you want?

    – Nathaniel M. Beaver
    Feb 20 '18 at 13:11











  • Cython is a popular optimizing static compiler for Python.

    – fpmurphy
    Feb 20 '18 at 13:15











  • wiki.python.org/moin/Freeze That method will compile executables for *nix systems. Although I'm not sure if that's what you want.

    – alpha
    Feb 20 '18 at 13:17











  • disassembling python code?

    – Rui F Ribeiro
    Feb 20 '18 at 13:22













  • Unless you mean create "precompiled" python modules (.pyc)?

    – xenoid
    Feb 20 '18 at 13:34














4












4








4


2






I need a program to compile python source code; as I found out at first I need to make a binary file from my python script.



I've already checked a lot of links, but still I haven't found something for Linux.



I found py2bin for OS/X, but there are no versions for Linux.










share|improve this question
















I need a program to compile python source code; as I found out at first I need to make a binary file from my python script.



I've already checked a lot of links, but still I haven't found something for Linux.



I found py2bin for OS/X, but there are no versions for Linux.







linux python compiler






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 20 '18 at 13:50









Jeff Schaller

40.6k1056129




40.6k1056129










asked Feb 20 '18 at 13:05









TrueBad0urTrueBad0ur

4814




4814













  • Python 2 or Python 3? Also, is Nuitka or dis closer to what you want?

    – Nathaniel M. Beaver
    Feb 20 '18 at 13:11











  • Cython is a popular optimizing static compiler for Python.

    – fpmurphy
    Feb 20 '18 at 13:15











  • wiki.python.org/moin/Freeze That method will compile executables for *nix systems. Although I'm not sure if that's what you want.

    – alpha
    Feb 20 '18 at 13:17











  • disassembling python code?

    – Rui F Ribeiro
    Feb 20 '18 at 13:22













  • Unless you mean create "precompiled" python modules (.pyc)?

    – xenoid
    Feb 20 '18 at 13:34



















  • Python 2 or Python 3? Also, is Nuitka or dis closer to what you want?

    – Nathaniel M. Beaver
    Feb 20 '18 at 13:11











  • Cython is a popular optimizing static compiler for Python.

    – fpmurphy
    Feb 20 '18 at 13:15











  • wiki.python.org/moin/Freeze That method will compile executables for *nix systems. Although I'm not sure if that's what you want.

    – alpha
    Feb 20 '18 at 13:17











  • disassembling python code?

    – Rui F Ribeiro
    Feb 20 '18 at 13:22













  • Unless you mean create "precompiled" python modules (.pyc)?

    – xenoid
    Feb 20 '18 at 13:34

















Python 2 or Python 3? Also, is Nuitka or dis closer to what you want?

– Nathaniel M. Beaver
Feb 20 '18 at 13:11





Python 2 or Python 3? Also, is Nuitka or dis closer to what you want?

– Nathaniel M. Beaver
Feb 20 '18 at 13:11













Cython is a popular optimizing static compiler for Python.

– fpmurphy
Feb 20 '18 at 13:15





Cython is a popular optimizing static compiler for Python.

– fpmurphy
Feb 20 '18 at 13:15













wiki.python.org/moin/Freeze That method will compile executables for *nix systems. Although I'm not sure if that's what you want.

– alpha
Feb 20 '18 at 13:17





wiki.python.org/moin/Freeze That method will compile executables for *nix systems. Although I'm not sure if that's what you want.

– alpha
Feb 20 '18 at 13:17













disassembling python code?

– Rui F Ribeiro
Feb 20 '18 at 13:22







disassembling python code?

– Rui F Ribeiro
Feb 20 '18 at 13:22















Unless you mean create "precompiled" python modules (.pyc)?

– xenoid
Feb 20 '18 at 13:34





Unless you mean create "precompiled" python modules (.pyc)?

– xenoid
Feb 20 '18 at 13:34










2 Answers
2






active

oldest

votes


















4














In my opinion your problem in Google stems for calling a compiler capable of producing binaries from python a "disassembler".



I have not found a true compiler, however I have found in Google a python compiler packager, which packs all the necessary files in a directory, obfuscating them, with an executable frontend: pyinstaller at http://www.pyinstaller.org/ ; it appears to be actively supported, as the last version 3.4 which was released on 2018-09-09, contrary to py2bin which seems to be not actively maintained.




Features:




  • Packaging of Python programs into standard executables, that work on
    computers without Python installed.

  • Multi-platform, works under:

    Windows (32-bit and 64-bit),

    Linux (32-bit and 64-bit),

    Mac OS X
    (32-bit and 64-bit),

    contributed suppport for FreeBSD, Solaris, HPUX,
    and AIX.

  • Multi-version:

    supports Python 2.7 and Python 3.3—3.6.




To install:




pip install pyinstaller


Then, go to your program’s directory and run:



pyinstaller yourprogram.py


This will generate the bundle in a subdirectory called dist.







share|improve this answer





















  • 3





    pyinstaller doesn't compile python programs, it just pack so that the result package can be used like a binary package. So practically an extractor and execution of normal python. (it use pyc, so simple reverse engineering is difficult, but a tools that change identifier should also be used, if reverse engineering is to avoid).

    – Giacomo Catenazzi
    Feb 20 '18 at 14:46











  • @GiacomoCatenazzi Thanks, I already suspected that. I also suspect it to be the case of py2bin, you can place scripts/python/perl programs under a "binary" package in MacOS.

    – Rui F Ribeiro
    Feb 20 '18 at 14:49






  • 1





    I doesn't know. On older time, there where a python to C (+compiler) (py2bin is so old, so maybe...). Cython could be a solution, but I doesn't know if and how the code should be modified (so it will be no more pure Python).

    – Giacomo Catenazzi
    Feb 20 '18 at 14:57











  • @GiacomoCatenazzi Thanks for your insights.

    – Rui F Ribeiro
    Feb 20 '18 at 15:04



















0














Is it work for linux??
I have created exe by using pyinstaller.






share|improve this answer








New contributor




Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f425394%2fhow-can-i-get-a-binary-from-a-py-file%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    In my opinion your problem in Google stems for calling a compiler capable of producing binaries from python a "disassembler".



    I have not found a true compiler, however I have found in Google a python compiler packager, which packs all the necessary files in a directory, obfuscating them, with an executable frontend: pyinstaller at http://www.pyinstaller.org/ ; it appears to be actively supported, as the last version 3.4 which was released on 2018-09-09, contrary to py2bin which seems to be not actively maintained.




    Features:




    • Packaging of Python programs into standard executables, that work on
      computers without Python installed.

    • Multi-platform, works under:

      Windows (32-bit and 64-bit),

      Linux (32-bit and 64-bit),

      Mac OS X
      (32-bit and 64-bit),

      contributed suppport for FreeBSD, Solaris, HPUX,
      and AIX.

    • Multi-version:

      supports Python 2.7 and Python 3.3—3.6.




    To install:




    pip install pyinstaller


    Then, go to your program’s directory and run:



    pyinstaller yourprogram.py


    This will generate the bundle in a subdirectory called dist.







    share|improve this answer





















    • 3





      pyinstaller doesn't compile python programs, it just pack so that the result package can be used like a binary package. So practically an extractor and execution of normal python. (it use pyc, so simple reverse engineering is difficult, but a tools that change identifier should also be used, if reverse engineering is to avoid).

      – Giacomo Catenazzi
      Feb 20 '18 at 14:46











    • @GiacomoCatenazzi Thanks, I already suspected that. I also suspect it to be the case of py2bin, you can place scripts/python/perl programs under a "binary" package in MacOS.

      – Rui F Ribeiro
      Feb 20 '18 at 14:49






    • 1





      I doesn't know. On older time, there where a python to C (+compiler) (py2bin is so old, so maybe...). Cython could be a solution, but I doesn't know if and how the code should be modified (so it will be no more pure Python).

      – Giacomo Catenazzi
      Feb 20 '18 at 14:57











    • @GiacomoCatenazzi Thanks for your insights.

      – Rui F Ribeiro
      Feb 20 '18 at 15:04
















    4














    In my opinion your problem in Google stems for calling a compiler capable of producing binaries from python a "disassembler".



    I have not found a true compiler, however I have found in Google a python compiler packager, which packs all the necessary files in a directory, obfuscating them, with an executable frontend: pyinstaller at http://www.pyinstaller.org/ ; it appears to be actively supported, as the last version 3.4 which was released on 2018-09-09, contrary to py2bin which seems to be not actively maintained.




    Features:




    • Packaging of Python programs into standard executables, that work on
      computers without Python installed.

    • Multi-platform, works under:

      Windows (32-bit and 64-bit),

      Linux (32-bit and 64-bit),

      Mac OS X
      (32-bit and 64-bit),

      contributed suppport for FreeBSD, Solaris, HPUX,
      and AIX.

    • Multi-version:

      supports Python 2.7 and Python 3.3—3.6.




    To install:




    pip install pyinstaller


    Then, go to your program’s directory and run:



    pyinstaller yourprogram.py


    This will generate the bundle in a subdirectory called dist.







    share|improve this answer





















    • 3





      pyinstaller doesn't compile python programs, it just pack so that the result package can be used like a binary package. So practically an extractor and execution of normal python. (it use pyc, so simple reverse engineering is difficult, but a tools that change identifier should also be used, if reverse engineering is to avoid).

      – Giacomo Catenazzi
      Feb 20 '18 at 14:46











    • @GiacomoCatenazzi Thanks, I already suspected that. I also suspect it to be the case of py2bin, you can place scripts/python/perl programs under a "binary" package in MacOS.

      – Rui F Ribeiro
      Feb 20 '18 at 14:49






    • 1





      I doesn't know. On older time, there where a python to C (+compiler) (py2bin is so old, so maybe...). Cython could be a solution, but I doesn't know if and how the code should be modified (so it will be no more pure Python).

      – Giacomo Catenazzi
      Feb 20 '18 at 14:57











    • @GiacomoCatenazzi Thanks for your insights.

      – Rui F Ribeiro
      Feb 20 '18 at 15:04














    4












    4








    4







    In my opinion your problem in Google stems for calling a compiler capable of producing binaries from python a "disassembler".



    I have not found a true compiler, however I have found in Google a python compiler packager, which packs all the necessary files in a directory, obfuscating them, with an executable frontend: pyinstaller at http://www.pyinstaller.org/ ; it appears to be actively supported, as the last version 3.4 which was released on 2018-09-09, contrary to py2bin which seems to be not actively maintained.




    Features:




    • Packaging of Python programs into standard executables, that work on
      computers without Python installed.

    • Multi-platform, works under:

      Windows (32-bit and 64-bit),

      Linux (32-bit and 64-bit),

      Mac OS X
      (32-bit and 64-bit),

      contributed suppport for FreeBSD, Solaris, HPUX,
      and AIX.

    • Multi-version:

      supports Python 2.7 and Python 3.3—3.6.




    To install:




    pip install pyinstaller


    Then, go to your program’s directory and run:



    pyinstaller yourprogram.py


    This will generate the bundle in a subdirectory called dist.







    share|improve this answer















    In my opinion your problem in Google stems for calling a compiler capable of producing binaries from python a "disassembler".



    I have not found a true compiler, however I have found in Google a python compiler packager, which packs all the necessary files in a directory, obfuscating them, with an executable frontend: pyinstaller at http://www.pyinstaller.org/ ; it appears to be actively supported, as the last version 3.4 which was released on 2018-09-09, contrary to py2bin which seems to be not actively maintained.




    Features:




    • Packaging of Python programs into standard executables, that work on
      computers without Python installed.

    • Multi-platform, works under:

      Windows (32-bit and 64-bit),

      Linux (32-bit and 64-bit),

      Mac OS X
      (32-bit and 64-bit),

      contributed suppport for FreeBSD, Solaris, HPUX,
      and AIX.

    • Multi-version:

      supports Python 2.7 and Python 3.3—3.6.




    To install:




    pip install pyinstaller


    Then, go to your program’s directory and run:



    pyinstaller yourprogram.py


    This will generate the bundle in a subdirectory called dist.








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 18 '18 at 15:17









    GC 13

    431213




    431213










    answered Feb 20 '18 at 13:33









    Rui F RibeiroRui F Ribeiro

    39.7k1479132




    39.7k1479132








    • 3





      pyinstaller doesn't compile python programs, it just pack so that the result package can be used like a binary package. So practically an extractor and execution of normal python. (it use pyc, so simple reverse engineering is difficult, but a tools that change identifier should also be used, if reverse engineering is to avoid).

      – Giacomo Catenazzi
      Feb 20 '18 at 14:46











    • @GiacomoCatenazzi Thanks, I already suspected that. I also suspect it to be the case of py2bin, you can place scripts/python/perl programs under a "binary" package in MacOS.

      – Rui F Ribeiro
      Feb 20 '18 at 14:49






    • 1





      I doesn't know. On older time, there where a python to C (+compiler) (py2bin is so old, so maybe...). Cython could be a solution, but I doesn't know if and how the code should be modified (so it will be no more pure Python).

      – Giacomo Catenazzi
      Feb 20 '18 at 14:57











    • @GiacomoCatenazzi Thanks for your insights.

      – Rui F Ribeiro
      Feb 20 '18 at 15:04














    • 3





      pyinstaller doesn't compile python programs, it just pack so that the result package can be used like a binary package. So practically an extractor and execution of normal python. (it use pyc, so simple reverse engineering is difficult, but a tools that change identifier should also be used, if reverse engineering is to avoid).

      – Giacomo Catenazzi
      Feb 20 '18 at 14:46











    • @GiacomoCatenazzi Thanks, I already suspected that. I also suspect it to be the case of py2bin, you can place scripts/python/perl programs under a "binary" package in MacOS.

      – Rui F Ribeiro
      Feb 20 '18 at 14:49






    • 1





      I doesn't know. On older time, there where a python to C (+compiler) (py2bin is so old, so maybe...). Cython could be a solution, but I doesn't know if and how the code should be modified (so it will be no more pure Python).

      – Giacomo Catenazzi
      Feb 20 '18 at 14:57











    • @GiacomoCatenazzi Thanks for your insights.

      – Rui F Ribeiro
      Feb 20 '18 at 15:04








    3




    3





    pyinstaller doesn't compile python programs, it just pack so that the result package can be used like a binary package. So practically an extractor and execution of normal python. (it use pyc, so simple reverse engineering is difficult, but a tools that change identifier should also be used, if reverse engineering is to avoid).

    – Giacomo Catenazzi
    Feb 20 '18 at 14:46





    pyinstaller doesn't compile python programs, it just pack so that the result package can be used like a binary package. So practically an extractor and execution of normal python. (it use pyc, so simple reverse engineering is difficult, but a tools that change identifier should also be used, if reverse engineering is to avoid).

    – Giacomo Catenazzi
    Feb 20 '18 at 14:46













    @GiacomoCatenazzi Thanks, I already suspected that. I also suspect it to be the case of py2bin, you can place scripts/python/perl programs under a "binary" package in MacOS.

    – Rui F Ribeiro
    Feb 20 '18 at 14:49





    @GiacomoCatenazzi Thanks, I already suspected that. I also suspect it to be the case of py2bin, you can place scripts/python/perl programs under a "binary" package in MacOS.

    – Rui F Ribeiro
    Feb 20 '18 at 14:49




    1




    1





    I doesn't know. On older time, there where a python to C (+compiler) (py2bin is so old, so maybe...). Cython could be a solution, but I doesn't know if and how the code should be modified (so it will be no more pure Python).

    – Giacomo Catenazzi
    Feb 20 '18 at 14:57





    I doesn't know. On older time, there where a python to C (+compiler) (py2bin is so old, so maybe...). Cython could be a solution, but I doesn't know if and how the code should be modified (so it will be no more pure Python).

    – Giacomo Catenazzi
    Feb 20 '18 at 14:57













    @GiacomoCatenazzi Thanks for your insights.

    – Rui F Ribeiro
    Feb 20 '18 at 15:04





    @GiacomoCatenazzi Thanks for your insights.

    – Rui F Ribeiro
    Feb 20 '18 at 15:04













    0














    Is it work for linux??
    I have created exe by using pyinstaller.






    share|improve this answer








    New contributor




    Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      0














      Is it work for linux??
      I have created exe by using pyinstaller.






      share|improve this answer








      New contributor




      Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        0












        0








        0







        Is it work for linux??
        I have created exe by using pyinstaller.






        share|improve this answer








        New contributor




        Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        Is it work for linux??
        I have created exe by using pyinstaller.







        share|improve this answer








        New contributor




        Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 24 mins ago









        MangoMango

        1




        1




        New contributor




        Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f425394%2fhow-can-i-get-a-binary-from-a-py-file%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Accessing regular linux commands in Huawei's Dopra Linux

            Can't connect RFCOMM socket: Host is down

            Kernel panic - not syncing: Fatal Exception in Interrupt