Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

macOS X weird python

short Q,

In a mac OS sierra terminal,

If I do:

whereis python
/usr/bin/python

Then if I do: /usr/bin/python it opens python 2.10

but if I execute python it opens python 2.7.8.

How can I know whereis python 2.7.8 and why whereis points to a different python version than the default one?

like image 419
Dnaiel Avatar asked Jan 18 '26 15:01

Dnaiel


1 Answers

whereis only looks in a few standard places. Use which -a python to get a list of directories in your PATH variable that contain python. For instance, on my machine

$ whereis bash
/bin/bash
$ which -a bash
/usr/local/bin/bash
/bin/bash
$ echo "$PATH"
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

As to why whereis does not report the python that actually runs, note in my example that whereis only reports /bin/bash. However, /usr/local/bin appears earlier in my PATH than /bin, so typing bash alone at a prompt runs the first one found while scanning PATH. In your case, you likely also have Python 2.7.8 in a directory that appears earlier in your path than /usr/bin.

like image 73
chepner Avatar answered Jan 20 '26 05:01

chepner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!