Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installs fine (OS X) but fails on import #10

Closed
dopplershift opened this issue Feb 26, 2014 · 10 comments
Closed

installs fine (OS X) but fails on import #10

dopplershift opened this issue Feb 26, 2014 · 10 comments

Comments

@dopplershift
Copy link
Member

From TGW...@gmail.com on January 20, 2009 14:06:03

I installed HDF5-1.8.2 and netcdf-4.0.1 from binaries (build to OS X on Intel). I installed
netCDF4-0.7.6 using setup.py install.

When I try to import netCDF4, I get this:

import netCDF4
Traceback (most recent call last):
File "", line 1, in
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/netCDF4.so, 2): Symbol not found: _H5P_CLS_FILE_ACCESS_g
Referenced from: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/netCDF4.so
Expected in: dynamic lookup

I'm a total noob. Any suggestions would be welcome.
Thanks.

Original issue: http://code.google.com/p/netcdf4-python/issues/detail?id=10

@dopplershift
Copy link
Member Author

From TGW...@gmail.com on January 20, 2009 16:37:08

I just rebuilt HDF5 and NETCDF-4 from source, and resinstalled NETCDF4-Python. Got the same error.
Built HDF5-1.8.2 with shared, with zlib and szlib. Built netcdf 4.0 with shared. Set HDF5_DIR and
NETCDF4_DIR and ran setup.py install. Started Python and tried to import netCDF4. All this in Mac OS 10.5.6.
Got:

import netCDF4
Traceback (most recent call last):
File "", line 1, in
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/netCDF4.so, 2): Symbol not found: _H5P_CLS_FILE_ACCESS_g
Referenced from: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/netCDF4.so
Expected in: dynamic lookup

Suggstions? Thanks in advance.
Ted

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on January 20, 2009 16:51:34

That error would mean one of two things:

  1. The HDF5 lib was not found by the linker
  2. The HDF5 lib in incomplete (does not have all the symbols netcdf 4 is looking for).

You can test (1) by running "otool -L
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/netCDF4.so" and see if the HDF5 lib is linked in and the path to the library
is correct.

Regarding (2), did you build HDF5 with --enable-hl (if not, you won't have all the
symbols netcdf 4 is looking for). In the same vein, did you build netcdf-4 with
--enable-netcdf-4 --with-hdf5=?

-Jeff

@dopplershift
Copy link
Member Author

From TGW...@gmail.com on January 20, 2009 17:45:47

Thanks for replying so quickly, Jeff.

I don't know what to look for in the output from otool, but I don't see anything that's obviously the HDF5 lib.
Here's what I got:
hemulen:~ Ted$ otool -L /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/netCDF4.so
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/netCDF4.so:
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.10)

So how would I go about helping the linker find the lib? (And wouldn't this have tripped up setup.py?)

(I did try rebuilding HDF5 and netcdf-4 with all the specified options. (I hadn't done the --enable-hl before.)
hemulen:~ Ted$ ./configure --prefix=/usr/local/hdf5 --with-zlib=/usr/local/zlib --with-
szlib=/usr/local/szlib --enable-shared --enable-hl
and
hemulen:netcdf-4.0 Ted$ ./configure --prefix=/usr/local/netcdf --with-hdf5=/usr/local/hdf5 --enable-
shared --enable-netcdf-4

No luck: same error. Seems like the problem is your hypothesis (1).)

Thanks,
Ted

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on January 21, 2009 09:51:38

Ted:

Yep, the linker can't find the HDF5 lib. You could set the environment variable
DYLD_LIBRARY_PATH to include where HDF5 is installed (/usr/local/hdf5/lib?).
However, you should not need to do this, since python's distutils is supposed to take
care of this for you when you build the extension. When you install netcdf4-python,
did you set the environment variable HDF5_DIR to /usr/local/hdf5? If not, it may
have picked up another version of HDF5 on your system (you should have seen a message
"HDF5 found in ..." when running setup.py).

-Jeff

@dopplershift
Copy link
Member Author

From TGW...@gmail.com on January 21, 2009 10:49:28

Jeff,

Solved it. I'd misnamed my szip directory, so my SZIP_DIR environment variable was wrong. I just reinstalled, and
the import went fine.

Thanks very much, again.
Ted

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on May 25, 2009 06:00:34

Status: Invalid

@dopplershift
Copy link
Member Author

From Ksamp...@gmail.com on February 16, 2011 22:14:45

Jeff,

I am having this exact same issue. I am using the Terminal window in MacOSX 10.6.6. I built HDF5 1.8.5-patch1 with shared. I also have zlib 1.2.5 and curl 7.21.3 (for OpenDAP). NetCDF4.1.1 was installed successfully with the following settings:

./configure --with-hdf5=/usr/local --prefix=/usr/local --enable-netcdf-4 --enable-shared --enable-dap

I followed the advice above and ran "python setup.py install" for NetCDF4-0.9.3, and it appeared to install successfully. However, the test doesn't run and I get the following traceback:

Traceback (most recent call last):
File "run_all.py", line 1, in
import glob, os, sys, unittest, netCDF4
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/netCDF4.so, 2): Symbol not found: _nc_close
Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/netCDF4.so
Expected in: dynamic lookup

When I used the otool -L command ("otool -L /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/netCDF4.so"), i got the following:

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/netCDF4.so (architecture ppc):
/usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 47.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11)
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/netCDF4.so (architecture i386):
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11)

I set the HDF5_DIR environment variable to "/usr/local". Not sure what else to try.

Kevin
ksampson ( at ) ucar (dot) edu

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on February 17, 2011 04:49:29

From the output of otool, it looks like you did not link the netcdf or hdf5 libs. Some things to check:

  1. shared libs for netcdf and hdf5 were actually installed in /usr/local.
  2. the env vars HDF5_DIR and NETCDF4_DIR are set to /usr/local.
  3. you ran 'python setup.py build' (without sudo), before running 'sudo python setup.py install'. sudo does not pass environment variables, so if you just run the install command you may not link the libs.

-Jeff

@dopplershift
Copy link
Member Author

From Ksamp...@gmail.com on February 17, 2011 23:07:25

I can confirm that I specified '--prefix=/usr/local' when installing the zlib, hdf5, and '--prefix=/usr/local --with-hdf5=/usr/local --enable-netcdf-4 --enable-shared' when installing netcdf. I followed all but your suggestion 3). I have now followed your suggestion 3) without 'sudo', and used the statements 'python setup.py build' and 'python setup.py install'. I had previously not known that it was necessary to build before installing. However, I have the exact same issues as before. The site-package appears to install, but i have the same issue with the '_nc_close' not being found.

Here is my new output from otool -L:

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/netCDF4.so (architecture ppc):
/usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 47.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11)
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/netCDF4.so (architecture i386):
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11)

It appears to be the same as before. I have a $HDF5_DIR environment variable set to '/usr/local', and a $NETCDF4_DIR environment variable set to '/usr/local'. Could it be that I need '/usr/local' closer to the beginning of my list directories in $PATH? Not sure what to try next.

Kevin

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on February 18, 2011 04:57:26

Kevin: Also see comments 5 and 6 in issue 21 . It could be that since python was build as a universal lib, and you are building the hdf5 and netcdf 4 libs are intel only. There are two possible remedies for this

  1. CFLAGS="-O3 -arch x86_64" LDFLAGS="-O3 -arch x86_64" python setup.py build

or

  1. edit

/Library/Frameworks/Python.framework/Versions/Current/lib/Python2.6/Makefile

and remove all references to "-arch ppc" and "-arch ppc64" (and perhaps -arch i386,
but that may not be necessary).

After you've done that, blow away your build directory and run "python setup.py
build" again.

-Jeff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant