You need to find out exactly what you are calling from Sublime Text. This solution ONLY applies if what others are saying is true and Sublime Text is calling another python interpreter that is different from the one that you are calling from the shell.
Step 1
Quick and dirty way to find out what Sublime Text is calling:
- Make Python your build system. Select on menu bar: Tools > Build System > Python
- Create new file (cmd+n)
- Build (cmd+b)
This should give you an error message like this:
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't find '__main__' module in ''
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u ""]
[dir: /Users/someuser/Downloads]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
The first line is giving you the path to python interpreter that Sublime Text is using.
Step 2
Next, you should find out what you are calling in the command line:
% which python
/usr/local/bin/python
Using the information above, you can locate where /usr/local/bin/python is by:
% ls -la /usr/local/bin/python
lrwxr-xr-x 1 someuser wheel 33 Jul 29 23:14 /usr/local/bin/python@ -> ../Cellar/python/2.7.5/bin/python
If that the two paths are the same, then stop: my solution will not apply to your situation.
Step 3
If the two paths are different, then you will need to either specifically use the path to the python interpreter that sublime text is calling:
% echo 'print "hello"' | /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
hello
Or, if you like to just use python to call in command line, then you can change the link that came up by "which python" (e.g., /usr/local/bin).
e.g. (DO NOT COPY AND PASTE THIS - please understand where the paths came from and why):
ln -s PATH_TO_YOUR_PYTHON /usr/local/bin/python
For better discussion about changing default python on OSX, see "How to change which Python version gets used in Snow Leopard?".
Another thing - if you want to run different python from Sublime Text, then take a look at this.