Re: ImportError: No module named Ngl

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Feb 11 2011 - 15:56:38 MST

I think that PyNGL should build fairly well on a Linux system if you already have NCL installed. If you have "libX11.so", that is probably enough.

Here are the bare minimum instructions that I think you need to build PyNGL on your system:

1. Install NCL

You already have NCL installed, so make sure it is working. First make sure NCARG_ROOT is set:

    printenv NCARG_ROOT

and then try typing:

    ncl -V

This should report "5.2.1".

To further test NCL and see if NCL and X11 are working, type:

    ng4ex xy01n -clean

This should pop up an X11 window with an XY plot. Click on this with your left-mouse button and it will go away.

2. Download the PyNGL-1.3.1 source code.

3. Set environment variables.

Before you try building PyNGL, make sure you do NOT have the HAS_CAIRO environment variable set. This will make PyNGL think you want to add cairo support, which requires a bunch of additional libraries.

Since NCL was likely built with gfortran, you will need to help the PyNGL installation find your gfortran library. To do this, set these two environment variables:

  setenv F2CLIBS gfortran
  setenv F2CLIBS_PREFIX /path/to/gfortran/libraries

On one of my LINUX boxes, I had to set F2CLIBS_PREFIX as follows:

  setenv F2CLIBS_PREFIX /usr/lib/gcc/i386-redhat-linux/4.1.1

4. Build PyNGL

Try building PyNGL with:

   python setup.py install

To test, cd somewhere away from the PyNGL-1.3.1 directory and type:

python
import Ngl

If any of this gives you problems, it helps if you can send me the output from the commands.

Thanks, and good luck,

--Mary

On Feb 10, 2011, at 11:09 AM, Jean-Francois Malouin wrote:

> Hi Mary,
>
> python-numpy is 1.3.0 for ubuntu repositary.
>
> I had a go at compiling PyNGL but failed miserably...
>
> I did install a pre-compiled version of ncl (ncl_ncarg-5.2.1)
> but I suspect my system is missing most of the dev packages
> needed to compile PyNGL. For instance I see libX11.so but not
> the archive lib libX11.a, etc. I'd rather not go this way if I can avoid it!

>
> regards,
> jf
>
>
> On Thu, Feb 10, 2011 at 12:45 PM, Mary Haley <haley@ucar.edu> wrote:
>> I have a feeling there's an incompatiblity issue with the version of gcc.
>>
>> Which version of numpy are you running? I'll see if I can build a PyNGL
>> on a system that's closer to yours, but I'm not sure when I can get to
>> it.
>>
>> Of course, you can try building PyNGL yourself from source code, but then you'll
>> need to install NCL, and you may have the same incompatibility
>> problems.
>>
>> --Mary
>>
>>
>> On Feb 8, 2011, at 9:06 PM, Jean-Francois Malouin wrote:
>>
>>> Here it goes:
>>>
>>> ~$ which python
>>>
>>> /usr/bin/python
>>>
>>> ~$ ls -la /usr/lib/python2.6/site-packages/PyNGL
>>>
>>> drwxr-sr-x 3 root staff 4096 2011-02-05 14:57 ./
>>> drwxrwsr-x 3 root staff 4096 2011-02-05 14:57 ../
>>> -rwxr-xr-x 1 root staff 289418 2011-02-05 14:57 fplib.so*
>>> -rw-r--r-- 1 root staff 8667 2011-02-05 14:57 hlu.py
>>> -rw-r--r-- 1 root staff 8074 2011-02-05 14:57 hlu.pyc
>>> -rwxr-xr-x 1 root staff 10251474 2011-02-05 14:57 _hlu.so*
>>> -rw-r--r-- 1 root staff 14 2011-02-05 14:57 __init__.py
>>> -rw-r--r-- 1 root staff 157 2011-02-05 14:57 __init__.pyc
>>> drwxr-sr-x 8 root staff 4096 2011-02-05 14:57 ncarg/
>>> -rw-r--r-- 1 root staff 249124 2011-02-05 14:57 Ngl.py
>>> -rw-r--r-- 1 root staff 187257 2011-02-05 14:57 Ngl.pyc
>>> -rw-r--r-- 1 root staff 97 2011-02-05 14:57 pyngl_version.py
>>> -rw-r--r-- 1 root staff 305 2011-02-05 14:57 pyngl_version.pyc
>>>
>>> ~$ cat /usr/lib/python2.6/dist-packages/Ngl.pth
>>> PyNGL
>>>
>>> ~$ python
>>> Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
>>> [GCC 4.4.5] on linux2
>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>> import sys
>>>>>> sys.path
>>> '', '/home/malin/PlanetaryClimateCourseware/CoursewareModules',
>>> '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2',
>>> '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old',
>>> '/usr/lib/python2.6/lib-dynload',
>>> '/usr/local/lib/python2.6/dist-packages',
>>> '/usr/lib/python2.6/dist-packages',
>>> '/usr/lib/python2.6/dist-packages/PyNGL',
>>> '/usr/lib/python2.6/dist-packages/PIL',
>>> '/usr/lib/python2.6/dist-packages/gst-0.10',
>>> '/usr/lib/pymodules/python2.6',
>>> '/usr/lib/python2.6/dist-packages/gtk-2.0',
>>> '/usr/lib/pymodules/python2.6/gtk-2.0']
>>>
>>> And this was my very first try at installing PyNgl.
>>>
>>> Thanks!
>>> jf
>>>
>>>
>>> On Tue, Feb 8, 2011 at 12:25 PM, Mary Haley <haley@ucar.edu> wrote:
>>>> Hi Jean-Francois,
>>>>
>>>> I'm hoping that the issue is not related to the fact that you downloaded a
>>>> PyNGL
>>>> that was compiled with gcc 4.3.2, and you are running gcc 4.4.5. I've never
>>>> tried this combo, so I don't know if it will work. I don't have a PyNGL
>>>> compiled
>>>> with gcc 4.4.5, unfortunately.
>>>>
>>>> First, though, let's make sure your current environment is set up correctly.
>>>>
>>>> Please let me know what the following reports on your system:
>>>>
>>>> which python
>>>> ls /usr/local/lib/python2.6/site-packages
>>>> ls /usr/local/lib/python2.6/site-packages/PyNGL
>>>> cat /usr/local/lib/python2.6/site-packages/Ngl.pth
>>>>
>>>> and then run python interactively to see what the system path looks like:
>>>>
>>>> python
>>>> import sys
>>>> sys.path
>>>> <ctrl-d>
>>>>
>>>> Finally, do you have any old PyNGL installations that might getting loaded
>>>> instead of the newer one?
>>>>
>>>> --Mary
>>>>
>>>> On Feb 8, 2011, at 8:30 AM, Jean-Francois Malouin wrote:
>>>>
>>>>> Thanks,
>>>>>
>>>>> I tried your suggestion: move the PyNgl stuff to
>>>>> /usr/lib/python2.6/dist-packages and after editing Ngl.py for the path
>>>>> I get:
>>>>>
>>>>> :~$ python
>>>>> Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
>>>>> [GCC 4.4.5] on linux2
>>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>>>>
>>>>>>>> import Ngl
>>>>>
>>>>> Segmentation fault
>>>>>
>>>>> hmmm,
>>>>> jf
>>>>>
>>>>> On Tue, Feb 8, 2011 at 4:27 AM, Nikolay Koldunov <koldunovn@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi, Jean-Francois
>>>>>>
>>>>>> Since you using Ubuntu, your problem might be related to renaming of
>>>>>> the site-packages to dist-packages in this distribution.
>>>>>> Solution to this is described here:
>>>>>> http://www.pyngl.ucar.edu/User_forum/Archives/2010/0119.html
>>>>>>
>>>>>> Hope it will help :)
>>>>>>
>>>>>> Kolya
>>>>>>
>>>>>>
>>>>>> On Tue, Feb 8, 2011 at 4:45 AM, Jean-Francois Malouin
>>>>>> <jfmalouin@gmail.com> wrote:
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> First post here.
>>>>>>>
>>>>>>> I saw the same problem here:
>>>>>>> http://www.pyngl.ucar.edu/User_forum/Archives/2009/0044.html
>>>>>>>
>>>>>>> but there was no solution provided afaik.
>>>>>>>
>>>>>>>> From Earth System Grid I downloaded the precompiled version of PyNGL
>>>>>>>> and ncl:
>>>>>>>
>>>>>>> PyNGL-1.3.1.linux-debian-i686-gcc432-py265-numpy141.tar.gz
>>>>>>> ncl_ncarg-5.2.1.Linux_Debian_i686_nodap_gcc412.tar.gz
>>>>>>>
>>>>>>> I installed PyNGL in /usr/local/lib/python2.6/site-packages/
>>>>>>>
>>>>>>> ls -la /usr/local/lib/python2.6/site-packages/
>>>>>>>
>>>>>>> -rw-r--r-- 1 root staff 6 2011-02-05 14:57 Ngl.pth
>>>>>>> drwxr-sr-x 3 root staff 4096 2011-02-05 14:57 PyNGL/
>>>>>>> -rw-r--r-- 1 root staff 540 2011-02-05 14:57 PyNGL-1.3.1-py2.6.egg-info
>>>>>>>
>>>>>>> and ncl_ncarg-5.2.1 in /usr/local/{bin,include,lib}
>>>>>>>
>>>>>>> I then set PYTHONPATH to
>>>>>>>
>>>>>>> export
>>>>>>> PYTHONPATH="~/PlanetaryClimateCourseware/CoursewareModules:/usr/local/lib/python2.6/site-packages"
>>>>>>>
>>>>>>> but no go to load the PyNGL module:
>>>>>>>
>>>>>>> python
>>>>>>> Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
>>>>>>> [GCC 4.4.5] on linux2
>>>>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>>>>>>
>>>>>>>>>> import Ngl
>>>>>>>
>>>>>>> Traceback (most recent call last):
>>>>>>> File "<stdin>", line 1, in <module>
>>>>>>> ImportError: No module named Ngl
>>>>>>>
>>>>>>> I must do something really stupid.
>>>>>>> Any help?
>>>>>>>
>>>>>>> My box:
>>>>>>>
>>>>>>> Linux bebe 2.6.35-25-generic #44-Ubuntu SMP Fri Jan 21 17:40:48 UTC
>>>>>>> 2011 i686 GNU/Linux
>>>>>>>
>>>>>>> malin@bebe:~$ lsb_release -a
>>>>>>> No LSB modules are available.
>>>>>>> Distributor ID: Ubuntu
>>>>>>> Description: Ubuntu 10.10
>>>>>>> Release: 10.10
>>>>>>> Codename: maverick
>>>>>>>
>>>>>>> ii python 2.6.6-2ubuntu2
>>>>>>> ii python-dev 2.6.6-2ubuntu2
>>>>>>> ii python-cairo 1.8.8-1
>>>>>>> ii python-gobject-cairo 2.21.5-0ubuntu3
>>>>>>> ii idle-python2.6 2.6.6-5ubuntu1
>>>>>>> ii python-numpy 1:1.3.0-3build1
>>>>>>> ii gcc 4:4.4.4-1ubuntu2
>>>>>>> ii gfortran 4:4.4.4-1ubuntu2
>>>>>>> Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
>>>>>>>
>>>>>>> thanks for the help!
>>>>>>> jf
>>>>>>> --
>>>>>>> "...things standing shall fall,
>>>>>>> but the moving shall ever stay."
>>>>>>> _______________________________________________
>>>>>>> pyngl-talk mailing list
>>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>>> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Nikolay Koldunov
>>>>>> University of Hamburg
>>>>>> Institute of Oceanography
>>>>>> KlimaCampus
>>>>>>
>>>>>> koldunovn@gmail.com
>>>>>> nikolay.koldunov@zmaw.de
>>>>>> ph. +49 40 42838 7580
>>>>>> Grindelberg 5, room 210,
>>>>>> 20144 Hamburg, Germany
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> "...things standing shall fall,
>>>>> but the moving shall ever stay."
>>>>> _______________________________________________
>>>>> pyngl-talk mailing list
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> "...things standing shall fall,
>>> but the moving shall ever stay."
>>> _______________________________________________
>>> pyngl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>>
>>
>
>
>
> --
> "...things standing shall fall,
> but the moving shall ever stay."
> _______________________________________________
> pyngl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Fri Feb 11 15:56:42 2011

This archive was generated by hypermail 2.1.8 : Fri Feb 11 2011 - 16:11:13 MST