Python 2.7 imports module from wrong location
Question: I'm on Python 2.7.6 un Ubuntu 14.04 and I'm trying to import openpyxl. I
upraged to a recent version via `sudo pip install openpyxl --upgrade` and `pip
show openpyxl` gives the following output:

    
    
    pip show openpyxl
    ---
    Name: openpyxl
    Version: 2.3.3
    Location: /usr/local/lib/python2.7/dist-packages
    Requires: 
    

However, when inside python, after I `import openpyxl` It seems to load it
from a different location: `/usr/lib` instead of `/usr/local/lib`

    
    
    openpyxl.__version__
    '1.7.0'
    openpyxl.__file__
    '/usr/lib/pymodules/python2.7/openpyxl/__init__.pyc'
    

I have set the `$PYTHONPATH` to `/usr/local/lib/python2.7/dist-packages`

And when looking at `sys.path` I get this output:

    
    
    ['', '/usr/local/lib/python2.7/dist-packages',... and 12 other locations]
    

It seems to have my desired location in first. Nevertheless the wrong module
gets loaded.

**EDIT:**

Contents of `$PATH`:

    
    
    /misc/software-lin/lmbsoft/build/x86_64-gcc4.8/release/bin:/misc/software-lin/lmbsoft/build/x86_64-gcc4.8/debug/bin:/misc/software-lin/lmbsoft/build/x86_64-gcc4.8/bin:/home/maid/phd/3rdpartySoft/art-2009-03-12/bin:/home/maid/phd/3rdpartySoft/ANTs-1.9.x-Linux/bin:/misc/software-lin/lmbsoft/build/x86_64-gcc4.8/release/bin:/misc/software-lin/lmbsoft/build/x86_64-gcc4.8/debug/bin:/misc/software-lin/lmbsoft/build/x86_64-gcc4.8/bin:/home/maid/phd/3rdpartySoft/art-2009-03-12/bin:/home/maid/phd/3rdpartySoft/ANTs-1.9.x-Linux/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:.:/home/maid/bin:/misc/software-lin/matlabR2015a/bin:/home/maid/phd/3rdpartySoft/nifty_reg-1.3/niftyreg_install/bin:/misc/software-lin/lmbsoft/cudatoolkit-3.2.16-x86_64/cuda/bin:/misc/database/cv2/local/bin:/misc/software-lin/vibez/bin:/usr/lib/jvm/java-6-openjdk/jre/bin:/misc/software-lin/vivi:/home/maid/localsoft/voreen/voreen-src-3.0.1-unix/bin/:/home/maid/tmp/ij146/ImageJ:.:/home/maid/bin:/misc/software-lin/matlabR2015a/bin:/home/maid/phd/3rdpartySoft/nifty_reg-1.3/niftyreg_install/bin:/misc/software-lin/lmbsoft/cudatoolkit-3.2.16-x86_64/cuda/bin:/misc/database/cv2/local/bin:/misc/software-lin/vibez/bin:/usr/lib/jvm/java-6-openjdk/jre/bin:/misc/software-lin/vivi:/home/maid/localsoft/voreen/voreen-src-3.0.1-unix/bin/:/home/maid/tmp/ij146/ImageJ
    

Any help appreciated, thanks, Dominic


Answer: I posit that if you `echo $PATH` you will find that `/usr/lib` is being
searched before `/usr/local/lib`. Because it finds it in `/usr/lib` first, it
will not go on to look in `/usr/local/lib`.

`sys.path` only covers the `$PYTHONPATH` variable and doesn't show you the
contents of `$PATH`.

