Skip to content Skip to sidebar Skip to footer

Why Is OSX Not Running The Python I Get With Whereis Python

I have a machine running OSX Yosemite (it has been through several versions of OSX, which may make a difference). I noticed an anomily with whether python could import libraries de

Solution 1:

Don't use whereis, that command ignores your PATH environment variable. From the manpage:

The whereis utility checks the standard binary directories for the specified programs, printing out the paths of any it finds.

Emphasis mine.

You have a PATH environment variable that includes a 'nonstandard' binary directory. Use which to find where python comes from:

$ which python

which gives you the actual binary used for your current shell configuration:

The which utility takes a list of command names and searches the path for each executable file that would be run had these commands actually been invoked.

You could use which -a to find all possible completions for the command:

$ which -a python

Also see “whereis” and “which” return different paths in Mac OS X on Super User.

Demo:

$ PATH=/opt/homebrew/bin:$PATH whereis python
/usr/bin/python
$ PATH=/opt/homebrew/bin:$PATH which -a python
/opt/homebrew/bin/python
/usr/bin/python

So even with PATH explicitly pointing to my homebrew directory, whereis ignores it. which finds it and lists it first (the -a argument made it look for more options).


Post a Comment for "Why Is OSX Not Running The Python I Get With Whereis Python"