How to Create .Pyc File to Run on Web

How to Create .Pyc File to Run on Web thumbnail
Compile your Python files and make them go faster.

Python is a popular open source scripting language. Unfortunately, as an interpreted, read-on-the-fly scripting language, it comes with the caveat of being slower than a compiled or statically converted to byte-code language. In high-traffic online applications, speed is critical. Conveniently, Python allows programmers the productivity of a high-level language, while allowing programmers to "compile" python code for greater speed. This makes Python ideal for the web environment, where both programmers and programs need to be fast.

Things You'll Need

  • Apache server
  • Python
  • Text editor
Show More

Instructions

    • 1

      Install Apache. If you're using Windows, the easiest way to do this is by using the WAMP or XAMPP packages. These packages install Apache through a point and click installer. If you're using Linux, Apache comes installed. Install MAMP if you're using a Mac.

    • 2

      Download mod_python from modpython.org. Install Python using mod_python. Installation instructions differ depending on the distribution of Apache you chose in the previous step. Consult your distribution's documentation for specific details. This entails copying the mod_python file to your Apache directory and modifying configuration files specific to the version of Apache being used.

    • 3

      Open your text editor. Type "print 'hello world'" and save your file. Copy this file to the home directory of your Apache installation. Usually this is a folder called "htdocs." Run the file by double-clicking on it. Python should have created a .pyc file in that directory. Whenever the original python file is run, the .pyc file is run instead.

Related Searches:

References

  • Photo Credit cluster disaster concept image by .shock from Fotolia.com

Comments

You May Also Like

  • What Is the File Extension PYC?

    Computer programming involves developing the applications that computers use to complete tasks. There are a number of different computer programming languages ...

  • How to Compile a Python File

    Python is slightly different from most other programming languages, both higher- and lower-level, in that it does not need to be compiled...

  • How to Create a Dictionary in Python

    In the Python programming language, a dictionary is a data structure that maps unique keys to values. In other programming languages, however,...

  • How to Open a Zipped File

    Zip archives are single files containing any number of compressed files. Zipping saves space, stores files cleanly and allows for easy transfer...

  • How to read a web page using Python

    This will show you how to read a web page from a python script given a URL.

  • How to Compile Python Code

    Since Python is an interpreted language, compilation of Python code can mean many things, including compilation to byte code or transformation to...

  • How to Generate an XSD From an XML File

    If you use XML data in your applications, it can be useful to have an XSD to check your structures against. XSD...

  • How to Create PDF Files

    PDF files are an important part to virtually any business that's online and plans to provide customers or visitors with information through...

  • How to Use Winrar to Unrar a File

    Winrar is a program that users of torrents commonly use to unpack a file called a rar. These files are similar to...

Related Ads

Featured