Closed GoogleCodeExporter closed 8 years ago
I guess the problem is this:
if sys.platform.startswith('win'):
regexp = re.compile('^netcdf.dll$')
If you're using Cygwin, I'm guessing the netcdf library is libnetcdf.so, not
netcdf.dll?
Original comment by whitaker.jeffrey@gmail.com
on 17 Sep 2013 at 5:33
On Cygwin, what does 'sys.platform' return? What is the name of the netcdf lib
in /home/tsigarid/lib/netcdf/lib? Is it libnetcdf.so?
Original comment by whitaker.jeffrey@gmail.com
on 17 Sep 2013 at 5:47
No, cygwin uses *.dll.a files, not *.so ones.
Original comment by tsiga...@gmail.com
on 17 Sep 2013 at 5:47
ls -la ~/lib/netcdf/lib/
drwxr-xr-x+ 1 tsigarid None 0 Aug 26 11:55 .
drwxr-xr-x+ 1 tsigarid None 0 Aug 26 11:53 ..
-rw-r--r-- 1 tsigarid None 2950816 Aug 26 11:53 libnetcdf.a
-rwxr-xr-x 1 tsigarid None 267386 Aug 26 11:53 libnetcdf.dll.a
-rwxr-xr-x 1 tsigarid None 950 Aug 26 11:53 libnetcdf.la
-rw-r--r-- 1 tsigarid None 10590 Aug 26 11:55 netcdfdll.def
drwxr-xr-x+ 1 tsigarid None 0 Aug 26 11:55 pkgconfig
Original comment by tsiga...@gmail.com
on 17 Sep 2013 at 5:49
>>> import sys
>>> sys.platform
'cygwin'
Original comment by tsiga...@gmail.com
on 17 Sep 2013 at 5:49
OK, I checked a possible fix in to svn HEAD. Could you check it out and let me
know how if works? It's just a small change to setup.py, here's the diff:
--- setup.py (revision 1290)
+++ setup.py (working copy)
@@ -62,6 +62,8 @@
if sys.platform.startswith('win'):
regexp = re.compile('^netcdf.dll$')
+ elif sys.platform.startswith('cygwin'):
+ regexp = re.compile(r'^libnetcdf.dll.a')
elif sys.platform.startswith('darwin'):
regexp = re.compile(r'^libnetcdf.dylib')
else:
Original comment by whitaker.jeffrey@gmail.com
on 17 Sep 2013 at 8:45
Still the same error. I did a bit of debugging, and this is where the problem
is:
python
>>> import ctypes
>>> ctypes.cdll.LoadLibrary('/home/tsigarid/lib/netcdf/lib/libnetcdf.dll.a')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: Exec format error
>>>
The file I'm trying to load exists, and this command is not used in the
setup.py of version 1.0.4. Do we have a suspect here?
Original comment by tsiga...@gmail.com
on 18 Sep 2013 at 8:12
Looks like that's the wrong DLL. Can you check to see if there is a
cygnetcdf-#.dll somewhere on your system? (in /usr/bin I think). I think
that's the one that needs to be loaded.
The problem arises now because I nned to check the version number of the
library (using ctypes) to see what version of the API it is. This is new in
1.0.5, since some functions were added to netcdf in version 4.3.1 that didn't
exist before.
Original comment by whitaker.jeffrey@gmail.com
on 18 Sep 2013 at 12:25
Yes there is, in /home/tsigarid/lib/netcdf/bin. /home/tsigarid/lib/netcdf is
where I've installed netcdf myself, since cygwin-x86_64 does not have (yet) the
netcdf library in the repository.
It appears that this library is going to work:
python
>>> import ctypes
>>> ctypes.cdll.LoadLibrary('cygnetcdf-7.dll')
<CDLL 'cygnetcdf-7.dll', handle 51aab0000 at 6ffffee6710>
>>>
Original comment by tsiga...@gmail.com
on 18 Sep 2013 at 12:31
OK, thanks for bearing with me. I updated setup.py again, so please give it
another try. The relevant code is in the function getnetcdfvers.
Original comment by whitaker.jeffrey@gmail.com
on 18 Sep 2013 at 3:01
Ugh. Can you please tell me what changes to do, or send me the updated
setup.py? I've never used svn, I doubt I even have it installed...
Original comment by tsiga...@gmail.com
on 18 Sep 2013 at 5:21
The new setup.py is attached here.
Original comment by whitaker.jeffrey@gmail.com
on 18 Sep 2013 at 5:32
Attachments:
Well done! This worked for me :D
python setup.py build
blah blah blah
using netcdf library version 4.3.0
blah blah blah
Success!
python
>>> import netCDF4
>>> netCDF4.__version__
'1.0.5'
Thank you.
Original comment by tsiga...@gmail.com
on 18 Sep 2013 at 5:37
Glad to hear it!
Original comment by whitaker.jeffrey@gmail.com
on 18 Sep 2013 at 6:16
Original comment by whitaker.jeffrey@gmail.com
on 26 Feb 2014 at 2:04
Original issue reported on code.google.com by
tsiga...@gmail.com
on 17 Sep 2013 at 4:01