Results 1 to 4 of 4

Thread: Compiling and Executing a Python program.

  1. #1
    Join Date
    Jan 2006
    Posts
    33

    Compiling and Executing a Python program.

    I have typed a program in Python and saved it as ‘myprog.py’. I want to compile it and execute?
    My screen is displaying,
    ___________________
    >>>
    ___________________


    It would be really helpful to know if there are any other Python compilers other than default python compiler. Can I send the pyhton source code that I have created to another person?

  2. #2
    Join Date
    Aug 2010
    Posts
    27

    Re: Compiling and Executing a Python program.

    Using CPyhton interpreter, your python source code will automatically be compiled. The compiled data will be created in PYO or PYC file. These PYO or PYC file will be automatically updated every time Python source code is updated.One can send this python files from one user to another by compressing it in .zip format.

    For creating an executable format of your Python code one can use bundling tools available like
    • Gordon McMillan’s installer (cross-platform)
    • Thomas Heller’s py2exe (Windows)
    • Anthony Tuininga’s cx_Freeze (cross-platform)
    • Bob Ippolito’s py2app (Mac)


    The above mentioned softwares creates an archive file of one’s created modules and data files and sets them up in an single executable file.

  3. #3
    Join Date
    Sep 2010
    Posts
    15

    Re: Compiling and Executing a Python program.

    Another software available for Windows is Squeeze, which archives all data files and modules in one single file. Combining it with Exemaker gives good results for creating executable files.

  4. #4
    Join Date
    Aug 2010
    Posts
    67

    Re: Compiling and Executing a Python program.

    Python automatically compiles Python source code.To create PYC file manually one can type,
    Code:
    >> >import <your file name>
    In your case ,
    Code:
    >> >import myprog.py
    This will create it’s PYC file in same folder/directory where you have saved the myprog.py file.The major drawback of the above method is that python compiles as well as executes the source code. This would create problems as every time it will execute incomplete source codes.

    To avoid this one can try,
    import py_compile
    py_compile.compile("mymodule.py")

    This only compiles the code and does not execute it.

Similar Threads

  1. Not able to see HDAPM program executing
    By Brandon67 in forum Portable Devices
    Replies: 4
    Last Post: 24-05-2010, 02:38 PM
  2. Executing java program via a script
    By Jensen Ackles in forum Software Development
    Replies: 5
    Last Post: 29-03-2010, 12:47 PM
  3. Executing a program with exec perl
    By Ash maker in forum Software Development
    Replies: 5
    Last Post: 08-03-2010, 02:02 PM
  4. How to find first index in list i.e. greater than x in python program?
    By Luis-Fernando in forum Software Development
    Replies: 5
    Last Post: 10-02-2010, 08:27 PM
  5. Getting an Error while Compiling the Java program
    By Rob Dizzle in forum Software Development
    Replies: 4
    Last Post: 18-01-2010, 10:24 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,065,799.90370 seconds with 17 queries