Sorry I should have been more clear, I'm running this on a computer that doesn't have any bitcoin software installed, just the wallet.dat file from my old computer, and pywallet.
For the wallet dump the command I ran was:
$ python pywallet.py --datadir=./ --wallet=wallet.dat --dumpwallet --dumpwithbalance > keys.txt
ERROR:root:Couldn't open wallet.dat/main. Try quitting Bitcoin and running this again.
I've tried changing the permissions of the wallet file with chmod, and running the command as sudo to make sure its not a permissions issue, but it still gives the same response...
Have you tried specifying the full path to the wallet file rather than just . ?? It's possible that the script is attempting to parse this as a full path and may not be locating the file correctly? I haven't looked at the actual code to see how the script is handling the --datadir argument, so I'm not 100% sure of the format required here.
When I get home from work tonight I'll have a proper look and and a bit of a play around with it and see if I can replicate and/or figure out some more specific solutions for you.