Course Three - Python language Environment
By ienex
Python is a versatile programming language available on all major operating systems, including Linux, macOS, and Windows. Before you start coding, it’s important to set up a local Python environment on your device.
Supported Platforms
Python can be installed on a wide variety of platforms, including:
-
Unix-based systems: Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX
-
Windows: Windows 9x, NT, 2000, Windows CE
-
macOS: Intel, PPC, 68K
-
Other systems: OS/2, DOS, PalmOS, Nokia mobile phones, Acorn/RISC OS, BeOS, Amiga, VMS/OpenVMS, QNX, VxWorks, Psion
To check if Python is already installed, open a terminal or command prompt and type:
python
This will display the installed Python version, if any.
Downloading Python
The official Python website, python.org, provides:
-
Source code
-
Binaries for different operating systems
-
Documentation in HTML and PDF
Download the version appropriate for your system. If a precompiled binary is unavailable, you can compile Python from source, which gives more flexibility and control over installation options.
Installing Python
On Unix/Linux
-
Open your web browser and go to python.org/download.
-
Download the source code for Unix/Linux.
-
Optionally, modify installation modules to customize settings.
-
Run the installation commands in the terminal.
After installation, Python libraries are typically stored in:
/usr/local/lib/pythonXX
where XX
represents your Python version.
On Windows
-
Go to python.org/download and select the Windows installer (
.msi
) for your version. -
Ensure your system supports Microsoft Installer (MSI).
-
Run the downloaded
.msi
file and follow the prompts. -
Accept default settings for a standard installation.
On macOS
macOS usually comes with Python preinstalled, but it may be outdated. To get the latest version:
-
Visit python.org/download/mac.
-
Follow the instructions to download and install the current version.
-
Additional tools may be required for development.
For troubleshooting or installation help on macOS, see MacPython Guide.
Setting the PATH Environment Variable
To run Python from any terminal or command prompt, you need to add Python to your system PATH.
On Unix/Linux
-
csh shell:
setenv PATH "$PATH:/usr/local/bin/python"
-
bash shell (Linux):
export PATH="$PATH:/usr/local/bin/python"
-
sh or ksh shell:
PATH="$PATH:/usr/local/bin/python"
Note:
/usr/local/bin/python
should be replaced with the actual path of your Python installation.
On Windows
-
Open the Command Prompt.
-
Enter the following:
set PATH=%PATH%;C:\Python
Note: Replace
C:\Python
with your actual Python installation directory.
Once the PATH is set, you can run Python from any terminal window without specifying the full path.
Python’s cross-platform availability and easy installation process make it simple to get started, whether you are on Windows, macOS, or Linux.
Comments
Post a Comment