Here, we are going to cover how to set up Python Installation in Windows and Mac.
1. Introduction
First, the easiest way to set up Python is to install one of the distributions of Python. Therefore, I would recommend Anaconda, which you can download and install free from https://www.anaconda.com/download/
In the download page, you can choose between the three operating systems
- Windows
- Mac
- Linux
The installation is fairly straightforward. After installation, you need to set up the PATH variable.
2. Setting PATH Variable
Since Python is an interpreted language, it means that the operating system would require the Python executable files.
The path to Python executable is stored in the environment variable which can be set by the user. To add the path to Python executable to the environment variable in Window:
- open the properties of My Computer
- Click on Advanced System Settings
- Then Environment Variables
- Select PATH from the list
- Click on Edit
- Then add the path to the Python executable to the end of the existing text.
3. Some Environment Variables to Know
These are some environment variables used by Python and you may encounter in Python Quiz
PYTHONSTARTUP
The PYTHONSTARTUP variable contains the path of the initialization file that contains the Python source code. It is processed each time the Python interpreter is started. In the Unix system, it’s name is .pythonrc.py and it holds the command that load utilities or modify the PYTHONPATH variable
PYTHONPATH
The variable plays a role similar to the PATH variable. It tells the Python interpreter the location of module files that are imported into the program. Additionally, contains the Python source library directory as well as the directories containing the Python source code.
PYTHONHOME
This specifies an alternative module search directory. It is normally embedded into the PYTHONSTARTUP or the PYTHONPATH directories. This in then, makes it possible to switch module libraries easily.
PYTHONCASEOK
Finally, this is a variable used in Windows to tell Python to find the first case-insensitive match in a module import statement. To activate this variable, it can be set to any value
[…] Outline 1. Introduction to Python Programming 2. Downloading and Installing Python in Your Computer 3. Write Your First Python Program 4. Variables and Data Types in Python 5. Operators in […]