Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-02-2012
Member
 
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?
Reply With Quote
  #2  
Old 15-02-2012
Member
 
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.
Reply With Quote
  #3  
Old 15-02-2012
Member
 
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.
Reply With Quote
  #4  
Old 15-02-2012
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 08:05 AM.