Skip to content Skip to sidebar Skip to footer

Updating Python For Use With AWS CLI

I'm trying to use AWS CLI S3 within the Terminal (Mac OS X v10.6.8) and after configuring all of the proper credentials when I run basic commands (e.g., aws s3 ls) it does not outp

Solution 1:

If you installed aws with the easy_install that came with Python 2.6, it will be hardcoded to use Python 2.6—its first line will be something like this:

#!/usr/bin/python2.6

This shebang line means that the script will run with /usr/bin/python2.6. Installing Python 3.3 won't change what's at /usr/bin/python2.6. It has nothing to do with what's on the PATH, or what the first thing called python is on the PATH. The PATH only comes into play if a script uses /usr/bin/env on the shebang line. And /usr/bin/env python2.6 would of course still find Python 2.6. In fact, even /usr/bin/env python would still find Python 2.6, because 3.3 doesn't have anything named python, just python3.

Meanwhile, even if you managed to hack it up to run with Python 3.3 instead (e.g., by changing that first line to /Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 or /usr/bin/env python3), that would just make it break completely. The aws script requires the aws package to be installed into your site-packages. You've installed them into your 2.6 site-packages, but not your 3.3 site-packages. (On top of that, many packages install different code for Python 2.x vs. 3.x, so the 2.6 script might not work with the 3.3 package even if it were there.)

Anyway, the right way to fix this is to uninstall aws from Python 2.6, and re-install it for Python 3.3.

If you'd used pip as recommended, this would be trivial:

pip-2.6 uninstall awscli
pip-3.3 install awscli

Unfortunately, because you used easy_install instead, you have to uninstall it manually.

And really, you don't need to uninstall the packages, just the scripts that ended up in /usr/local/bin or somewhere else on your PATH. I suspect rm /usr/local/bin/aws* will take care of that, but be careful—make sure there's nothing else installed there that starts with aws but isn't part of the package.

Meanwhile, for the future, install pip and use that. For Apple's Python 2.6, use sudo easy_install pip to install it. For Python 3.3, follow the instructions at the pip site.


Post a Comment for "Updating Python For Use With AWS CLI"