On Friday, May 18, 2012, Chao YUE wrote: > Dear all, > > This is only a small python import question. I think I'm right but just > want some confirmation. > > Previously I have installed numpy 1.5.1. and then I used pip install > --upgrade numpy > to install numpy 1.6.1 > > But when I try to import numpy as np within ipython shell, I still get the > version 1.5.1 > > then I checked my sys.path: > > In [21]: sys.path > Out[21]: > ['', > '/usr/local/bin', > '/usr/local/lib/python2.7/dist-packages/pupynere-1.0.15-py2.7.egg', > '/usr/lib/pymodules/python2.7', > > '/usr/local/lib/python2.7/dist-packages/scikits.statsmodels-0.3.1-py2.7.egg', > > '/usr/local/lib/python2.7/dist-packages/Shapely-1.2.13-py2.7-linux-i686.egg', > > '/usr/local/lib/python2.7/dist-packages/pandas-0.7.3-py2.7-linux-i686.egg', > '/home/chaoyue/python/python_lib', > '/usr/lib/python2.7', > '/usr/lib/python2.7/plat-linux2', > '/usr/lib/python2.7/lib-tk', > '/usr/lib/python2.7/lib-old', > '/usr/lib/python2.7/lib-dynload', > '/usr/local/lib/python2.7/dist-packages', > '/usr/lib/python2.7/dist-packages', > '/usr/lib/python2.7/dist-packages/PIL', > '/usr/lib/pymodules/python2.7/gtk-2.0', > '/usr/lib/python2.7/dist-packages/gst-0.10', > '/usr/lib/python2.7/dist-packages/gtk-2.0', > '/usr/lib/pymodules/python2.7/ubuntuone-client', > '/usr/lib/pymodules/python2.7/ubuntuone-control-panel', > '/usr/lib/pymodules/python2.7/ubuntuone-storage-protocol', > '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode', > '/usr/local/lib/python2.7/dist-packages/IPython/extensions'] > > Actually I found I have numpy 1.5.1 in /usr/lib/pymodules/python2.7 > > and numpy 1.6.1 in /usr/local/lib/python2.7/dist-packages/numpy/ > > but because the first path is before the second one in sys.path, so > ipython imports only the first one and ignore the second one. > Then I delete the directory of /usr/lib/pymodules/python2.7/numpy and redo > the import, I get the version 1.6.1 > > This means that import will try to find the first occurrence of the module > and will ignore the ones with same name in later occurrences? > > cheers, > > Chao > > Yes. This is actually very common. The $PATH environment variable works the same way for finding executables.
Ben Root > >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion