osx - MacPorts pHash not showing up in Python

06
2014-04
  • Nitzan Wilnai

    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.

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    osx - `which python` points to the python I want, but `python` runs the wrong version
  • tramdas

    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:

    1. I believe the path is set up sensibly, and which python seems to confirm this.
    2. 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?


  • Related Answers
  • Ignacio Vazquez-Abrams

    Try hash -d python. This will tell bash to forget where it last saw the python executable.

  • 8088

    Perhaps you just updated something and your bash instance has stale information about executables. Try exec bash.

    When I:

    1. Start qqq (/usr/bin/qqq) from bash.
    2. Add something qqq to /usr/local/bin/.
    3. Try to start qqq again in the same bash.

    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.

  • GreenMatt

    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