Setting up a Python Development Environment on OSX – Part 1 – Introduction

By , August 8, 2011

When setting up a new project or re-building a machine I usually Google quick tutorials on setups as I forget syntax or gotchas for tasks I often do once and forget about them. This is a log so I can reference my own setup. If you find it useful that’s just swell.

I am assuming you will have a clean install of OSX Lion.

  • Part 1 – Introduction – xcode, checking python version, sql lite, installing pip and iPython
  • Part 2 – Source Control – Installing Git, creating SSH keys and setting up GitHub, installing GitHub for Mac
  • Part 3 – VirtualENV – Installing VirtualEnv to create and manage virtual environments for projects
  • Part 4 – IDE – Configuring Pycharm (to use virtualEnv’s and adding useful extensions)
  • Part 5 – Pulling it all together

Note: As I have written this I have taken the approach of incrementally explaining how things work. There are short-cuts and ways to improve things which are all pulled together in the last post “Pulling it all together”

Part 1 – The Introduction

This is the really simple stuff! Before you do anything install X-Code from the AppStore. The C compiler that ships with X-Code is often needed when you install Python modules later.

X code

Check to make sure you have a working version of Python and SQL Lite just use python –version and sqlite3 -version. Lion ships with a healthy Python 2.7.1 and SQLite 3.7.5.

Python version

Next use easy_install to install pip the excellent Python package / module manager. Note: In the screen shot I use –upgrade to force a re-install for the blog only. “sudo easy_install pip” will install pip and “pip help” will list the basic commands when installed.

Pip

No with pip installed you can install your first useful package, iPython. iPython has a better interactive shell that is very useful when exploring the interpreter. “sudo pip install ipython” does the trick!

Ipython

Tomorrow Part 2 – Source Control - Installing Git, creating SSH keys and setting up GitHub, installing the GitHub for Mac client.

Share on TwitterSubmit to reddit
  • Anonymous

    If you don’t want to install the whole Xcode (lots of GB’s of disc space) you could instead use the OS X GCC for Lion installer, which only installs the GCC things (less than 300mb). You can find it at https://github.com/kennethreitz/osx-gcc-installer

  • Anonymous

    Great tip!

Panorama Theme by Themocracy