Hey folks, welcome back, in this module, I am going to discuss How to set up Python Environment. Since, we have covered a lot of things related to Python like Features of Python, Applications of Python, and many more.
So, it’s my turn to start working with Python Environment Setup.
How to set up Python Environment?
Since we know that one can work with python on any platform whether it is Windows, Linux, or Mac. And the main thing is where you will write your code in Python language. You can write it in a WordPad or a Notepad. Before executing any Python code, we need a Python setup/installer installed in our system using which our system will be able to execute Python code.
How to install Python?
Let’s see how we can install python on different platforms. We will cover them all one by one.
How to install Python on the Windows platform?
For installing Python on the Windows platform, follow the steps that are given below.
- Open your web browser and open the official python page from where you can download the python installer i.e., https://www.python.org/downloads/
- Click on the Windows hyperlink.
- Click on the link for the Windows Installer named in the format “python-PQR.msi” where PQR is the version that you want to install. The latest version for Windows is Python 3.9.4.
- Your Windows system must support the Microsoft installer 2.0, only then you will be able to run the installer.
- Once downloaded, save the installer file to your local machine and then run it to find out whether your machine supports MSI or not.
- If everything is on track, the Python Installation Wizard will appear on the screen.
- Accept all the settings with their defaults and wait till the installation gets completed.
- Once the installation is complete, it’s done and Python is installed in your system successfully.
How to install Python on Linux and Unix platforms?
Let’s see the steps to install Python on the Linux/Unix platform.
- Open your web browser and open the official python page from where you can download the Python installer/package i.e., https://www.python.org/downloads/
- Click on the Linux/Unix hyperlink.
- You can find the link to download the zipped source code for Linux/Unix.
- Download the file and extract the same in your system.
- If you want some options to be customized, then you can edit the module/setup files.
- Make install
- Python will get installed at the standard location i.e., /usr/local/bin and its libraries will be stored at /usr/local/lib/pythonXX where XX depicts the version of Python.
How to install Python on the MAC OS platform?
Visit the Python website i.e., https://www.python.org/downloads/mac-osx/
- All the instructions are present there for you to get the current version of Python with extra tools which will enable our system to support the development in MAC.
- If your MAC OS is older, i.e., if it was released in 2003 or the version is MAC OS X 10.3, that a separate package named MacPython is available.
- Recent versions of MAC are shipped with Python pre-installed in it.
Upon the completion of the installation process, the next step is to set the path. Let’s see why it is necessary and how to do it.
How to Set up Path for Python?
Many programs and other executable files are stored in different directories in our system. An operating system provides a search path that lists the directories to be searched by OS for executables.
The path variable is named Path in windows and PATH in Linux/Unix. One thing to be noted here is that Linux is case-sensitive whereas Windows is not.
How to set up the path of Windows platforms?
To set the directory of python to the particular path in the windows platform, follow the given steps.
- Open the command prompt and type path %path%;C:\Python and then press Enter. Here, the path of the python directory is C:\Python
How to set up the path in Linux/Unix platforms?
To set the python directory to the Unix platform’s path, follow the given steps.
- Open the csh shell and type setenv PATH “$PATH:/usr/local/bin/python” and press then Enter.
- Open the Bash Shell (Linux) and type export PATH=”$PATH:/usr/local/bin/python” and press hit Enter.
- In the sh or ksh shell, type PATH=”$PATH:/usr/local/bin/python” and then press Enter.
- Here, the path of the python directory is /usr/local/bin/python.
How to set up the path in the Mac OS platform?
In Mac OS, the path details are handled by the installer itself. Now, if you want to invoke the Python interpreter from any directory, you have to add the Python directory to your environmental path of the system.
Later, you can start Python by adding commands in the command line interpreter or in the shell window. Enter the ‘python’ command in the command line and start coding.
Python can be accessed through a graphical user interface (GUI) as well. For this, you must have a GUI-based application in your system that supports Python.
Windows: You should have an IDE i.e., Integrated Development Environment. For example, PythonWin, which is the oldest IDE available for windows.
Linux/Unix: You should have IDLE, it is the very first IDE for the Unix platform.
I hope you all liked How to set up Python Environment? module and must be very excited to start your journey towards learning the python programming language in detail. So, stay connected until the next module. Stay safe, keep learning, and Happy coding!