Your First Program in Python 3 on Mac OS X. This page tells you how to setup a Python programming environment for your Mac OS X computer and provides a step-by-step guide for creating and running a simple 'Hello, world' Python program.
![]()
![]()
Python 3 is available for Windows, Mac OS and most of the flavors of Linux operating system. Even though Python 2 is available for many other OSs, Python 3 support either has not been made available for them or has been dropped.
Local Environment Setup
Open a terminal window and type 'python' to find out if it is already installed and which version is installed.
Getting PythonWindows platform
Binaries of latest version of Python 3 (Python 3.5.1) are available on this download page
The following different installation options are available.
Note − In order to install Python 3.5.1, minimum OS requirements are Windows 7 with SP1. For versions 3.0 to 3.4.x Windows XP is acceptable.
Linux platform
Different flavors of Linux use different package managers for installation of new packages.
How To Install Python 3 For Mac
On Ubuntu Linux, Python 3 is installed using the following command from the terminal.
Installation from source
Download Gzipped source tarball from Python's download URL − https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
Mac OS
Download Mac OS installers from this URL − https://www.python.org/downloads/mac-osx/
Double click this package file and follow the wizard instructions to install.
The most up-to-date and current source code, binaries, documentation, news, etc., is available on the official website of Python −
Python Official Website − https://www.python.org/
You can download Python documentation from the following site. The documentation is available in HTML, PDF and PostScript formats.
Python Documentation Website − www.python.org/doc/
Setting up PATH
Programs and other executable files can be in many directories. Hence, the operating systems provide a search path that lists the directories that it searches for executables.
The important features are −
Setting Path at Unix/Linux
To add the Python directory to the path for a particular session in Unix −
Note − /usr/local/bin/python3 is the path of the Python directory.
Python Version 3 For MacSetting Path at Windows
To add the Python directory to the path for a particular session in Windows −
Note − C:Python is the path of the Python directory
Python Environment Variables
Here are important environment variables, which are recognized by Python −
Running Python
There are three different ways to start Python −
Interactive Interpreter
You can start Python from Unix, DOS, or any other system that provides you a command-line interpreter or shell window.
Brew Install Python 3.6
Enter python the command line.
Start coding right away in the interactive interpreter.
Here is the list of all the available command line options −
Script from the Command-line
A Python script can be executed at the command line by invoking the interpreter on your application, as shown in the following example.
Note − Be sure the file permission mode allows execution.
Integrated Development Environment
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 not able to set up the environment properly, then you can take the help of your system admin. Make sure the Python environment is properly set up and working perfectly fine.
Note − All the examples given in subsequent chapters are executed with Python 3.4.1 version available on Windows 7 and Ubuntu Linux.
We have already set up Python Programming environment online, so that you can execute all the available examples online while you are learning theory. Feel free to modify any example and execute it online.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |