Open a terminal window and type "python" to search out if it is already placed and which version is installed.
The least up-to-date and actual source code, binaries, confirmation, news, etc., is accessible on the official website of Python https://www.python.org/
Users are able to download Python documentation from https://www.python.org/doc/. The tutorials are accessible in HTML, PDF, and PostScript formats.
Python preparation are accessible for various platforms. Users require downloading only the binary code relevant for the platform and installing Python.
If the binary code for the respective platform is not accessible, then you demand a C compiler to compile the source code extremity. Compiling the source code provides much flexibility in terms of selections of features that you necessitate in your installation.
Here is a speedy overview of installing Python on different platforms:
This installation of Python happens at standard location /usr/local/bin and its libraries at /usr/local/lib/pythonXX where XX is the version of Python.
Here are the various steps to install Python on a Windows machine.
Recent Macs launch with Python installed, but it may be various years out of date. See http://www.python.org/download/mac/ for instructions on acquiring the current version along with extra tools to aid development on the Mac. For previous Mac OS's versions such as Mac OS X 10.3 (released in 2003), MacPython is obtainable.
Jack Jansen handles the installation and you could have full access to the whole documentation at his website- http://www.cwi.nl/~jack/macpython. You arise to discover the complete installation items for Mac OS installation.
Programs files and other associated executable files could be in numerous directories, so operating systems render a search path that lists the directories that the OS searches for executable.
The path is stored in an environment covariant, which is a personage as a string handled by the OS. This variable compromise of information accessible to the command shell and other programs.
The path changeable is named PATH in Unix or Path in Windows (Unix is case sensitive; Windows is not).
In Mac OS, the installer manages the path facts. To boost the Python interpreter from any special directory, you must line the Python directory to the path.
To add the Python directory to the path for a significant session in Unix-
To add the Python directory to the path for a particular session in Windows -
At the command prompt - type path %path%;C:\Python and press Enter.
Note - C:\Python is the path of the Python directory
Sr.No. | Variable & Description |
1 | PYTHON PATH It has a function akin to PATH. This changeable define the Python interpreter where to locate the module files imported into a program. It should exclude the Python source library directory and the directories incorporating Python source code. PYTHONPATH is erstwhile preset by the Python installer. |
2 | PYTHONSTARTUP It comprises of the path of an initialization file comprising Python source code. It is delivered every time you begin the interpreter. It is named .pythonrc.py in Unix and it includes commands that load utilities or modify PYTHONPATH. |
3 | PYTHONCASEOK It is utilized in Windows to instruct Python to discover the first case-insensitive match in an import statement. Set this uncertainty to any value to actuate it. |
4 | PYTHONHOME It is an alternate module to find the path. It is normally embedded in the PYTHONSTARTUP or PYTHONPATH directories to sort switching module libraries easily. |
There are three most important ways to begin Python-
You can begin Python from Unix, DOS, or any other system that supports you with a command-line interpreter or shell window.
Enter python the command line.
Beginning the coding writing in the interactive interpreter.
$python # Unix/Linux or python% # Unix/Linux or C:> python # Windows/DOS
Here is the list of all the accessible command-line selections-
Sr.No. | Option & Description |
1 | -d It offers to debug output. |
2 | -O It constitutes optimized bytecode (resulting in .pyo files). |
3 | -S Do not run import sites to search for Python paths on startup. |
4 | -v verbose output (detailed trace on import statements). |
5 | -X disable class-based built-in exceptions (just use strings); obsolete starting with version 1.6. |
6 | -c cmd run Python script sent in as cmd string |
7 | file run Python script from given file |
A Python script is a significant option to be executed at the command line by including the interpreter on the application, as in the following
$python script.py # Unix/Linux or python% script.py # Unix/Linux or C: >python script.py # Windows/DOS
Note- Be sure the file permission mode authorizes execution.
You can run Python from a Graphical User Interface (GUI) environment as well if you have a GUI application on your system that supports Python.
If you are about to set up the environment decently, then you could take aid from your system admin. Ensure the Python environment is properly set up and executing perfectly fine.
Note - Each example given in the following chapters is executed with Python 2.4.3 version easy to get to on CentOS flavor of Linux.
We already have set up a Python Programming environment online, so that you can execute entire the accessible examples online at the same time when you are educating the theory. Stay on alert to modify any instance and execute it online.
Now, the path is set, we are ready to run python on our local system. Restart CMD, and type python again. It will open the python interpreter shell where we can execute the python statements.
To install python3 on macOS, visit the link https://intellinuts.com/python/how-to-install-python-on-mac and follow the instructions given in the tutorial.
To install Python3 on CentOS, visit the link https://intellinuts.com/python/how-to-install-python-3-on-centos and follow the instructions given in the tutorial.
To install Python3 on Ubuntu, visit the link https://intellinuts.com/python/how-to-install-python-on-ubuntu and follow the instructions given in the tutorial.
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.