1

I have used python's netCDF4 package maybe 100 times on my Mac. Today, I tried

>>> from netCDF4 import Dataset

as I have done countless times, and was told

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/netCDF4/__init__.py", line 3, in <module>
    from ._netCDF4 import *
ImportError: dlopen(/Library/Python/2.7/site-packages/netCDF4/_netCDF4.so, 2): Library not loaded: /opt/local/lib/libhdf5.100.dylib
  Referenced from: /Library/Python/2.7/site-packages/netCDF4/_netCDF4.so
  Reason: image not found

I suspect that this is related to an update I did through Mac Ports yesterday, but don't know for sure. Anyone know the solution?

UPDATE: I don't have libhdf5.100.dylib in the directory where netCDF4 wants to find it, but I do have libhdf5.101.dylib. Any way to convince netCDF4 to look for that instead? Would setting up a link be a safe thing to do?

UPDATE AGAIN: Found an answer about an hour later if anyone is interested. It is given below.

bob.sacamento
  • 6,283
  • 10
  • 56
  • 115

1 Answers1

1

OK, after goofing around for about an hour, I hit on this:

Use pip to uninstall netCDF4, then turn right around and use pip to install it again. Everything now works fine.

BTW, the initial uninstall is critical. And, on my machine at any rate, I had to run everything under sudo.

bob.sacamento
  • 6,283
  • 10
  • 56
  • 115