Make Your Own Python Compiler
Linux tutorials and code.
5 posts
Page 1 of 1
One thing that's great about Python is that it allows us to compile it into a bytecode (.pyc)
First open up your terminal and navigate into the directory in which your program's file(s) are, for example my files are in a folder called ScreenScare on my desktop, so I would put down the following terminal command to access that directory (NOTE: The terminal is case sensitive).
First open up your terminal and navigate into the directory in which your program's file(s) are, for example my files are in a folder called ScreenScare on my desktop, so I would put down the following terminal command to access that directory (NOTE: The terminal is case sensitive).
Code: Select all
Now I would type these terminal commands in order.
cd Desktop/ScreenScare
Code: Select all
NOTE: You can save the code below into a compiler.py file to compile your applications, but don't forget to change the appname.python
import compiler
compiler.compileFile("appname.py")
exit()
Code: Select all
After you've compiled your program now it's time to make the .pyc file executable by putting down the following terminal command.
import compiler
compiler.compileFile("appname.py")
exit()
Code: Select all
and now it's time to run the program with this terminal command.
sudo chmod +x appname.pyc
Code: Select all
./helloworld.pyc
Last edited by mikethedj4 on Mon Oct 11, 2010 4:26 pm, edited 1 time in total.
If you have python installed on windows or a mac this will work as a compiler for all platforms.
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023