Python - Environment Setup
Python is available on a wide variety of platforms including Linux and Mac OS X. Let’s understand how to set up our Python environment.
- Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.)
- Win 9x/NT/2000
- Macintosh (Intel, PPC, 68K)
- OS/2
- DOS (multiple versions)
- PalmOS
- Nokia mobile phones
- Windows CE
- Acorn/RISC OS
- BeOS
- Amiga
- VMS/OpenVMS
- QNX
- VxWorks
- Psion
Python has also been ported to the Java and .NET virtual machines
Local Environment Setup
- Open a Terminal or Command Prompt:
- On Windows, you can press
Win + R
, typecmd
, and press Enter. - On macOS, you can use
Cmd + Space
to open Spotlight, typeTerminal
, and press Enter. - On Linux, you can open the terminal using the appropriate shortcut for your distribution.
- On Windows, you can press
- Check if Python is Installed:
- Type the following command and press Enter:
python --version
If Python is installed, you will see the version number. For example:
Python 3.8.5
- If you see an error or if Python is not installed, you might see a message like:
'python' is not recognized as an internal or external command,
operable program, or batch file.
- Type the following command and press Enter:
- Check Python Version:
- If Python is installed, but you want to check the version separately, use:
python -V
or
python --version
- This will display the Python version installed on your system.
- If Python is installed, but you want to check the version separately, use:
- Check for Python 3:
- Some systems use
python3
instead ofpython
for Python 3.x versions. To check Python 3 version, use:python3 --version
- If Python 3 is installed, you will see the version number.
- Some systems use
Remember that the exact commands may vary slightly based on your operating system and how Python was installed. If Python is not installed, you can download and install it from the official Python website.
Installing Python on Windows:
Visit the Official Python Website:
Open your web browser and go to the official Python website: https://www.python.org/
Navigate to Downloads:
On the homepage, you’ll find a “Downloads” tab. Click on it to go to the downloads section.
Download Python:
On the downloads page, you will see the latest stable version of Python. Click on the “Download Python x.x.x” button (x.x.x represents the version number).
Choose Installer Options:
The website will automatically detect your operating system. If you are using a 64-bit version of Windows, the recommended download will be the 64-bit version. If you have a 32-bit system, you can choose the 32-bit version.
If you are unsure about your system architecture, you can check by right-clicking on “This PC” or “Computer” on your desktop or File Explorer and selecting “Properties.”
Start Installer Download:
Click on the “Save File” button to download the installer. The file should have a name like python-x.x.x.exe (where x.x.x is the version number).
Run the Installer:
Once the download is complete, locate the installer file and double-click on it to run the Python installer.
Customize Installation (Optional):
On the first installation screen, you’ll see an option to “Add Python x.x to PATH.” It’s recommended to check this box as it makes it easier to run Python from the command line. Click on “Customize installation” if you want to customize the installation settings.
Complete Installation:
Click “Next” to proceed through the installer. You can leave the default settings as they are for most users.
Click “Install” to start the installation process.
Verify Installation:
Once the installation is complete, you can verify it by opening a Command Prompt and typing:
python –version
You should see the installed Python version.
Access Python IDLE (Optional):
Python comes with an Integrated Development and Learning Environment (IDLE). You can access it by typing “IDLE” in the Start menu and selecting “IDLE (Python x.x)”.
Congratulations! You have successfully installed Python on your Windows system. You can now start writing and running Python programs.