Tag Archives: python

Not a Python Programmer

If someone asks you if you’re a Python (or Java, or Javascript or language X) programmer, how do you respond? This year, my answer will be “No. I’m not a Python programmer, I’m a programmer”

Last year, I wrote production code in:

  • Python
  • Ruby
  • Javascript
  • Java
  • Objective-C
  • C
  • Powerpoint (only joking!)

I narrowly avoided writing code in Erlang, and considered writing some getting-to-know you Golang, but alas writing all the other code ate the available time.

As one of my Comp Sci professors said many years ago, learning any language takes a day or two provided you’re familiar with the language style (functional, imperative, OO etc etc). What takes the time is learning the libraries and the idiom. However, I’ve noticed that this takes way less time than it did back in the day, thanks to Google, Github and Stack Overflow.

Now, if you have a “there must be a better way” feeling when working with a new language, it’s the work of moments to find it and learn the relevant idiom. As an aside: one of the great disappointments of last year was realising how shockingly bad the idioms for writing network code on Android are.

So I’m a programmer first and foremost, who uses whichever tool makes sense while trying to cultivate a constant sense of laziness and curiosity. Laziness so I look for the easy way, and the curiosity to find it.

Let’s see which languages make the list in 2014…

OS X Mavericks: Fixing broken Python development environments

Upgrading to OS X Mavericks (10.9) broke my Python development environment by deleting the contents of  /Library/Python/2.7/site-packages and X11. Why an OS upgrade should be deleting things I put there is another question, but here’s how to get back up.

My Mac Python setup is reasonably standard I think: I use a system-wide install of some basic stuff (virtualenv, pip, easy_install) and then virtualenvs for all development.

After upgrading, existing virtualenvs were fine – the problem started when I wanted to create a fresh one. Suddenly virtualenv wasn’t there, and once virtualenv had been restored pip found it impossible to build several of the libraries that I depend on (including Pillow, lxml, gevent – basically anything with a C library dependency).

Step 1: Get virtualenv back

cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command
python easy_install.py virtualenv

Step 2: Create a virtualenv and try installing the modules you need

virtualenv <path>
pip install -r <your requirements file>

If all installs fine, then you’re done! If like me you get errors, here’s some of the things that are probably missing:

Step 3: Reinstall X11 (required for Pillow / PIL)

Download from XQuartz.org

Step 4: Reinstall XCode command line tools

Install the latest XCode (currently 5.0.1) then install the command line tools:

xcode-select --install

Step 5: Repair homebrew

If you’re using Homebrew for access to various open source packages – and I strongly recommend you do – then you may need to repair things.

brew update
brew upgrade
brew doctor

and follow the recommendations

After all this, you should find you’re back where you were before Mavericks, and able to build and install Python modules. Happy hacking!