[Numpy-discussion] python import question

Chao YUE chaoyuejoy at gmail.com
Fri May 18 17:49:56 EDT 2012


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

-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120518/83fb8b51/attachment.html>


More information about the NumPy-Discussion mailing list