I installed Python 2.7 and pip following these instructions, on Mac OS X v10.10.3 (Yosemite).
I can successfully install packages and import them inside my Python environment and Python scripts. However, any executable associated with a package that can be called from the command line in the terminal are not found.
For example, I tried to install a package called "rosdep" as instructed here. I can run sudo pip install -U rosdep
which installs without errors and the corresponding files are located in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
. However, sudo rosdep init
subsequently reports that the rosdep
command is not found.
I even tried adding the above site-packages
path to my $PATH
, but the executables are still not found on the command line, even though the packages work perfectly from within python.
Why does this happen, and how can I fix it?
See also: Unable to import a module that is definitely installed - these two problems often have the same root cause.
Check your $PATH environment variable.
tox
has a command line mode:
$ pip list | grep tox
tox (2.3.1)
Where is it?
(The 2.7
stuff doesn't matter much here, sub in any 3.x
and pip's behaving pretty much the same way)
$ which tox
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/tox
And what's in my $PATH?
$ echo $PATH
/opt/chefdk/bin:/opt/chefdk/embedded/bin:/opt/local/bin:..../opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin...
Notice the /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin? That's what allows finding my pip-installed stuff
Now, to see where things are from Python, try doing this (substitute rosdep
for tox
).
$python
>>> import tox
>>> tox.__file__
that prints out:
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tox/__init__.pyc'
Now, cd to the directory right above lib
in the above. Do you see a bin directory? Do you see rosdep
in that bin? If so, try adding the bin
to your $PATH.
$ cd /opt/local/Library/Frameworks/Python.framework/Versions/2.7
$ ls -1
Output:
Headers
Python
Resources
bin
include
lib
man
share