Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between running "python" and "python2.7" on a Mac OS X?

Tags:

python

macos

When I run python from a terminal on my Mac, I get the following first two lines back:

Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

When I run python2.7, I get this:

Python 2.7.5 (default, May 19 2013, 13:26:46)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin

I can recognize scipy and numpy in python2.7, but not in plain python.

What precisely is the difference between these? Is there any way I can make python import scipy? Can I just alias python2.7 to python and forget about this?

like image 411
Buck Shlegeris Avatar asked Mar 11 '26 06:03

Buck Shlegeris


2 Answers

Those are two different pythons.

Try whereis python and whereis python2.7 to get their specific locations.

like image 190
Bleeding Fingers Avatar answered Mar 13 '26 21:03

Bleeding Fingers


On a Mac (at lesat with OS X 10.7.0 through the latest 10.8.x), the pre-installed Python at /usr/bin/python and /usr/bin/python2.7 is Apple's 2.7.2 build.

If you have two different 2.7.5 builds, you must have installed them manually. And nobody but you can possibly know how you did that.

The which command may help. For example, you may find that the first python on your PATH is a /usr/local/bin/python which is a symlink to /usr/local/Cellar/python/2.7.5/bin/python, while the first python2.7 on your PATH is /opt/local/bin/python2.7, which is an executable. That would mean that you installed a Homebrew Python 2.7.5, and you also installed a MacPorts Python 2.7.5, and you did the latter in such a way that it didn't create a python symlink, and you've got MacPorts higher on your PATH than Homebrew.

But whatever you've done, it scarcely matters. If you don't understand how to manage this stuff yourself, the best thing to do is to uninstall all of the extra Pythons you installed and just use a single Python 2.7. That means you will need to reinstall any modules, of course, but it's worth doing.

I know some people believe that it's worth getting one additional Python 2.7 installation and using that in place of Apple's, but nobody is going to tell you to get two additional Python 2.7 installations and use both of them.

like image 25
abarnert Avatar answered Mar 13 '26 20:03

abarnert