How To Setup Sublime Text For Python Mac

This tutorial is for Windows users who want to get their computer set up for developing with Python.

What is Python?

Python is a programming language that is easy to learn, yet powerful and flexible. Many professional software engineers use Python every day to do their job, for both large projects and small ones. Python is free, open source, and it runs on Windows, Mac, and Linux, as well as many other operating systems. It's a great language if you want to start learning how to write computer programs.

What Do I Need?

To effectively use Python on Windows, you need a few pieces of software:

  • Sublime Text or another text editor

Let's handle them one at a time.

Installing Python

Go to python.org and download the version of Python that you want. In these examples, I'm downloading Python 3.2.3.

Run the installer, and let it install to the default location: in this case, C:Python32.

Python Setup: Install Python On Mac OSX + Sublime Text blake March 22, 2018 Python Tutorials No Comments How to install Python on a Mac and setup a work environment. Update Sublime Text 3 to Python 3 on Mac. This blog will explain how to update Sublime Text 3 to build with Python 3 on a mac. Step 1: Make sure your computer has Python 3 installed on it.

That was easy!

Installing Cygwin

This is a bit more complicated. First, go to the Cygwin homepage, download setup.exe, and run it.

Cygwin is a program that can download and install other programs from the internet for you. You'll need to give it some information about your internet connection, although most of the time you can just accept the defaults and keep going.

Next, Cygwin will show you a long list of download sites. Each one is exactly the same: you can pick one at random. You do not need to pick the same download site shown in the screenshot. After you've picked one and clicked the 'next' button, you'll see an upgrade warning, but that only applies to people upgrading from an older version of Cygwin. Since this is a new installation, we can ignore it.

Now, we get to select what software we want to install from the download site. We want to install three software packages: openssh, git, and curl. For each one, use the search box to find the package, and then click on the word 'Skip' so that it changes to a version number. Install the latest available version for each of these packages.

Next, Cygwin will tell you that you need to install certain other packages as dependencies. Basically, this means that if you want to use a certain package named A, and A relies on another package named B in order to run correctly, then Cygwin will detect this and ask to install package B as well. You can just hit 'Next'. At that point, Cygwin will start downloading and installing all the packages that you've requested, as well as all their dependencies. Depending on the speed of your internet connection, this may take a little while. When the middle of the three progress bars (the one marked 'Total') is full, Cygwin is finished.

If you ask Cygwin to install an icon on your desktop, it will do so, creating a shortcut named 'Cygwin Terminal'. You'll use this icon to run your Python code, as well as to access the openssh, git, and curl packages that you installed. Double-click the icon to run Cygwin Terminal, and you'll see a window like this pop up:

The exact text in your terminal window will be a little different, since it depends on the name of your computer, and the name of your user account. Now we can start using the terminal: if you don't know how, I suggest you readthis tutorial on how to use the command line.First, let's use the which command to find out where those packages are that we installed:

So it looks like the terminal can find ssh and git, but not python. That's understandable, since we didn't use Cygwin to install Python. To tell Cygwin how to find Python, run the following command:

Note that you're using the same directory that you installed Python into: if you're installing a different version of Python, then replace Python32 with the version of Python you have installed. You should only need to do this once: after you've run that command, the terminal will always be able to find Python again.

You're finally done installing and setting up Cygwin!

Installing Sublime Text

Lastly, you'll need a text editor. There are many good options, but I suggestSublime Text: it's very powerful and useful, and it has an unlimited free trial. Please note that Microsoft Word is a word processor, not a text editor: you cannot use Microsoft Word for writing computer programs.

Installing Sublime Text is easy: just go to the Sublime Text homepage, download the installer, and install it. Sublime Text is not free software, but you can try it for as long as you like before you buy it. If you end up writing many programs using Sublime Text, I encourage you to buy a license.

Verify that it all works

Sublime

Now that you're all set up, let's verify that everything is working properly! The first program that any programmer writes is called 'Hello, World!', and all it does is write that text out to the terminal. So, let's write 'Hello, World!' in Python! If your computer is set up properly, this should work properly:

If that works, lets move on to writing a program into a file. Open up Sublime Text, and type in the following:

Save the file in your home directory (inside of C:cygwinhome) as hello.py. Then open up the Terminal, cd to that directory, and run:

And you should see the same Hello, World! output that you saw before. Congratulations, you're ready to start learning Python!

Please enable JavaScript to view the comments powered by Disqus.

Installing Python and Sublime Text 2on a Windows 7 or Mac OS X Computer

Python 2.7.x,the development language for this course, may already be installed in some formon your laptop. Likewise, you may already have Sublime Text 2. The instructionshere are general guidelines for getting the packages onto your Windows PC or MacOS X computer. You can also set both environments up for Linux but since I don’thave a Linux machine right now, you will have to work that out on your own.

Installing Python

On a Windows PC:

First, checkto see if you already have Python. Open up a command window. On Windows 7,click the Start button and type cmd in the textbox (for other versions of Windows, google “open command prompt windows X”). Awindow with a command prompt will open. In the command prompt window, type python. If you get a message saying that Python is not recognized,then you will need to install it on your computer. If Python does start, checkthe version. If it is 3.x, you will still need to download version 2.7.x. Also,make sure that ‘Anaconda’ is mentioned somewhere in the starting info. If it isnot, you should continue with the installation instructions. Type quit() at the >>>> prompt and Python will exit.

If you donot have version 2.7.x of Python, clickhere to get the Python Anaconda distribution. Anaconda includes a Pythoninterpreter and many other helpful tools for Python programming. Click the Python 2.7 Windows 64-bit graphicalinstaller and follow the instructions.

On a Mac (OS X):

Sublime

First, checkto see if you already have Python. Open up Terminal. The easiest way is to openSpotlight with + in the text field. Double click onTerminal under applications. In Terminal, type python. If you get a message saying that Pythonis not recognized, then you will need to install it on your computer. If Pythondoes start, check the version. If it is 3.x, you will still need to downloadversion 2.7.x. Also, make sure that ‘Anaconda’ is mentioned somewhere in thestarting info. If it is not, you should continue with the installationinstructions. Type quit() at the prompt and Python will exit.

If you donot have version 2.7.x of Python, clickhere to get the Python Anaconda distribution. Anaconda includes a Pythoninterpreter and many other helpful tools for Python programming. Click the Python 2.7 Mac OS X 64-bit graphicalinstaller and follow the instructions.

How To Setup Sublime Text For Python Mac

Installing Sublime Text 2

Sublime Text2 is available for both Windows PCs and Macs running OS X. Click here to getWindows and OS X installers.

Testing your installation

StartSublime Text 2. Enter

How To Setup Sublime Text For Python Mac

‘hello python’

in the textwindow.

Save thefile somewhere with a name like HelloPython.pyIt is very important to save the file with a .pyextension before the next step.

On Windows,type ctrl-B. On the Mac, type +

Using Sublime With Python

In bothcases, your program should run and should beprinted at the bottom of the frame. You can exit Sublime—all is well. Ifnothing happened, make sure to save your file with a .py extension and try again.