osx - MacPorts pHash not showing up in Python
2014-04
I am having a problem where python does not show pHash installed even though I installed it using macports.
I made sure I am using the MacPorts version of Python by doing:
sudo port select --set python python27
I then installed pHash by doing:
sudo port install pHash.
It installed without any errors.
When I call help('modules'), I do not see pHash listed among the installed packages.
Any ideas on why python is not seeing the pHash install by MacPorts?
Calling port select --list python shows the following:
Available versions for python:
none
python25-apple
python26-apple
python27 (active)
python27-apple
Printing out sys.path outputs the following: (reformatted to make it easier to read here)
['/Library/Python/2.7/site-packages/boto-2.9.9-py2.7.egg',
'/Library/Python/2.7/site-packages/setuptools-0.9.8-py2.7.egg',
'/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
'/Library/Python/2.7/site-packages']
Can anyone help?
Thanks.
Edit - some more information:
This is where MacPorts claims it installed pHash
$ port contents pHash
Port pHash contains:
/opt/local/include/audiophash.h
/opt/local/include/pHash-config.h
/opt/local/include/pHash.h
/opt/local/include/ph_fft.h
/opt/local/lib/libpHash.0.dylib
/opt/local/lib/libpHash.a
/opt/local/lib/libpHash.dylib
/opt/local/lib/pkgconfig/pHash.pc
/opt/local/share/doc/pHash/AUTHORS
/opt/local/share/doc/pHash/COPYING
/opt/local/share/doc/pHash/ChangeLog
Here is some of the output from help('modules') showing that python can't find pHash:
_Win contextlib optparse tty
__builtin__ cookielib os turtle
__future__ copy os2emxpath types
_abcoll copy_reg parse_s3_photos_to_rds unicodedata
_ast crypt parser unittest
_backport csv pdb upload_photos_to_s3
_bisect ctypes pickle urllib
_bsddb curses pickletools urllib2
_builtinSuites datetime pimp urlparse
_codecs dbhash pip user
_codecs_cn dbm pipes uu
_codecs_hk decimal pkg_resources uuid
Thanks.
I want to use python24 provided by ports, so I've installed it, and python_select -s
shows that the version I want is indeed selected. Running which python
gives /opt/local/bin/python
, and running /opt/local/bin/python
gives me the version I want. However when I run python
from the shell, I get the /usr/bin/python
version instead. I don't have a python alias.
Here's the situation in a nutshell:
- I believe the path is set up sensibly, and
which python
seems to confirm this. alias
only returns 1 entry, which is something unrelated to this.
Nevertheless, running python
from the bash shell gives me the wrong python!
I'm kind of stumped! What am I overlooking?
Try hash -d python
. This will tell bash to forget where it last saw the python executable.
Perhaps you just updated something and your bash instance has stale information about executables. Try exec bash
.
When I:
- Start
qqq
(/usr/bin/qqq
) frombash
. - Add something
qqq
to/usr/local/bin/
. - Try to start
qqq
again in the samebash
.
It uses the already-looked-up version (/usr/bin/qqq
)
However when I restart the bash, it looks for qqq
again and gets /usr/local/bin/qqq
.
Another possibility is that the script itself specifies which Python executable to run in the first line of the script. For example, my system has Python 2.6 and 2.7 installed, and if the first line is something like:
#!/usr/bin/Python-2.6.8/bin/python
then I get Python 2.6, even though 2.7 is the system default.
The usual way to specify the default is:
#!/usr/bin/env python