Python for Mac OS X
Python comes pre-installed on Mac OS X so it is easy to startusing. However, to take advantage of the latest versions ofPython, you will need to download and install newer versionsalongside the system ones. The easiest way to do that is toinstall one of the binary installers for OS X from thePython Download page. Installers areavailable for the latest Python 3 and Python 2 releases thatwill work on all Macs that run Mac OS X 10.5 and later.
Python releases include IDLE, Python's built-in interactivedevelopment environment. If you download and install Pythonfrom the release page, you may also need to download and installa newer version of Tcl/Tk for OS X. See theIDLE and Tkinter on OS X page formore information.
Open the Terminal.app and type which python, and on a fresh install of Snow Leopard you should see: /usr/bin/python This is a symlink that points to your actual Python installation. Next, type cd /usr/bin; ls -l python2.6, and the output should be something.
Select an x86 installer in case you have a 32-bit system.Python windows, Linux/Unix, Mac OS X. Also read: Best Antivirus For Windows 10/8.1 PC Download free INSTALL PYTHON ON WINDOWS/MAC Python in digital surroundings created with both digital or pyvenv, then PIP shall be obtainable to that surroundings no matter Python model. The Python core team thinks there should be a default you don't have to stop and think about, so the yellow download button on the main download page gets you the 'x86 executable installer' choice. This is actually a fine choice: you don't need the 64-bit version even if you have 64-bit Windows, the 32-bit Python will work just fine.
You can run a Python interpreter by double-clicking onApplications / Utilities / Terminal and typing python3 (if you'veinstalled a version of Python 3) or python (to use Python 2) inthe window that opens up. You can also launch IDLE for the Pythonversion you have installed by double-clicking its icon inthe appropriate Python version folder in the Applications folderor you can also just type idle3 or idle in a terminal window.
There are many thousands of additional Python software packagesavailable through PyPI, the PythonPackage Index. We recommend you use thepip tool to simplifyinstalling and managing additional packages. pip is includedwith Python 3.4 releases; for earlier releases, follow the pipinstall instructions.
Among the packages available through PyPI are some that arespecifically for OS X environments. Among these are:
- pyobjc which providesa bridge between Python and Objective-C, allowing you to writefull-featured native Cocoa applications in pure Python.
- py2app which allowsyou to make standalone OS X double-clickable application bundlesand plugins from Python scripts.
For more information about Python on OS X, see the mailing list and archivesfor thePython-Macintosh Special Interest Group.
Alternative Packages for Mac OS X.
- ActiveState ActivePython(commercial and community versions, including scientific computing modules).
- Enthought Python DistributionThe Enthought Python Distribution provides scientists with a comprehensive setof tools to perform rigorous data analysis and visualization.
Python and a comprehensive set of third-party packages and libraries are alsoavailable from several open source package manager projects for OS X,including:
Hello, World!
To start, we need to get some things straight.
Programs are recipes you write to make your computer do things. These recipes are written in aprogramming language, which is a language close enough to human for you to write, and organized enough for a computer to read. Python is one of the most popular programming languages.
When you write a program, you’re just writing a text file (similar to a word document, or an email, or a short story).
When you run a program, you’re giving that text file to Python, and Python is making your computer do stuff.
Programs can do all kinds of stuff, like printing, calculating with numbers, reading a website, or sending a file.
The first program we’re going to write in this tutorial is the classic “Hello World”. Our version will print the words “Hi, Everybody!” onto the screen.
When you’re beginning to learn to program, it’s hard to do all the fancy graphics necessary to make a website or a phone app. So, to start out, most programmers learn to program using the command line. The command line is a program where you type commands and the computer outputs results. It looks like something used by old school hackers on television:
The command line is where you’ll run your first few programs. But it’s not where you’ll write them. Just as there are good places to write documents (Microsoft Word) and emails (Gmail), and good places to edit photos (Photoshop) and draw pictures (Illustrator), there are good places to write programs.
Since programs are written in text, it’s good to write them in a text editor. A text editor is just a program for writing. Microsoft Word and Gmail are text editors, but they have special features which get in the way of writing programs.
Programming has its own text editors. They range from the very light weight (some programmers just use a basic notepad) to the very heavyweight (big development environments like Eclipse and Visual Studio will automatically complete some of your code for you).
We will use a middleweight program called Sublime Text. Sublime looks like a simple notepad, but it provides what is called syntax highlighting. Programs are organized text, so showing them in colors helps highlight the important parts:
Sublime Text is available at http://www.sublimetext.com/2. Download the OS X copy, open the dmg file you downloaded, and drag the Sublime icon to your Applications folder. It is also a good idea to add this program to your dock.
The command line program in OS X is called Terminal. You can find it in your Applications folder inside another folder called Utilities.
Open Sublime to a blank file. In that file, write:
Save this file to your home directory as “helloworld.py”.
Later we will learn how to navigate files at the terminal, but for now, saving to your home directory will allow use to run the program without worrying about where it is located.
![Can Can](/uploads/1/2/6/3/126359555/830999540.png)
Notice how after you save the file, Sublime starts highlighting it, turning the word “print” one color, and the text another color. This is because, by naming the file with a “.py” at the end, you’ve helped Sublime to guess that this is a python file, and it has applied Python language highlighting.
Python For Mac Os
Open the Terminal program. Some text is printed to say who you are and when you last logged in, but we’ll worry about that later. Right now, we’re only concerned with the prompt. The prompt is the line you’re currently typing on. You can type anything you want, but when you press enter, your computer will assume you have given it a command and try to execute that command.
We will command the computer to run our new Python program. At the prompt, type the following and press enter:
On the line below the prompt, the terminal should print:
Below this line, it should print another prompt, indicating that it is waiting for you to give another command.
Can You Download Python On Macbook
And there you go! You made the computer print something out to the terminal.
In the Python language, the word “print” tells the computer to output text to the terminal. The text you want to print is wrapped in quotes. So,
![Download Download](/uploads/1/2/6/3/126359555/553362384.jpg)
tells the computer to print the text “Hi, Everybody!”.
Can I Download Python On Mac
In the next post, you will learn how to use Python to do calculations and print numbers.