Creating Software in Python
Published: 2020-06-15 16:18:52

Before we get around to explaining how to create software using Python, let's list down some basic differences between an actual software and the small scripts. 

1.A Graphical User Interface (GUI)
2.Exception Handling 
3.Logging System
4.Software is compiled code that is executed
5.Scripts are interpreted
6.Script are typically a single file program
7.Software may consists of several smaller programs working together


#Required Python Skills

It is fairly obvious that anyone attempting to create software should be sufficiently skilled in the core concepts of Python. However we'll be discussing certain types of skills here that aren't part of the core concepts (loops, functions, File Handling), but essential when it comes to making software. You can skim over this section if you read our [Top Coding Practices](https://coderslegacy.com/top-11-coding-practices-for-great-coders/) article instead. Everything is explained in much more detail there with supporting code and images. 

There are several things that are acceptable while you are simply creating scripts or practicing programming, such as taking input from the console, debugging with the use of print statements, letting errors crash your program etc. However, when making software, especially software made for distribution to users, several things must be kept in mind. 

Three main things which we'll discuss briefly here are Logging, GUI's and Exception handling. Have you every used a software without a helpful User interface? Would you pick a console based software over a GUI based software? For obvious reasons, all software should have a helpful and user friendly GUI. If you don't know how to implement a GUI, head over to our Python GUI section where the [various GUI libraries](https://coderslegacy.com/python/python-gui/) are discussed (After you read this article that is).

Next up is Exception handling. When an error occurs, your entire program crashes. This is unacceptable in a software, especially larger ones. Many of us encounter errors while using software, but instead of the program crashing, an error message is displayed instead. This is [exception handling](https://coderslegacy.com/python/python-exception-handling/), where a good implementation can catch any exceptions and take an alternate route instead to maintain stability.  

Using print statements to help you during debugging is a practice discouraged at higher levels. We have a proper system for this purpose called Logging. It involves system events that occur to be saved within a file, complete with details about that event such as the exact time is occurred. This is also useful because you can ask your customers to send you their log file if their software produces an error. Using this file you can then figure out what went wrong. 


#Pyinstaller

Python doesn't natively come with a way to create compiled programs. However, pyinstaller is a python library that can be used for this purpose. You install it as you would a regular library using the pip install pyinstaller command in the cmd, and then follow the below steps. 
 
1. Go to the command prompt, and navigate to the file you wish to convert. In this case, we'll be converting a file called "TestFile.py". First we navigate to the directory where our File is stored. In our case, Desktop. 

2. Once you've successfully reached your python file, run the "pyinstaller TestFile.py" command, and pyinstaller will take care of the rest. 

This is a very basic implementation of pyinstaller. In a more real life scenario, there will likely be many more issues. There's a good chance the default pyinstaller compiler settings won't work for you. Luckily there are many alternate settings available, such as the --onefile setting.

For the full article, check the original article at [CodersLegacy](https://coderslegacy.com/).