[Nexus] Nexus with python on windows

Jon Wright wright at esrf.fr
Tue Nov 20 08:08:26 GMT 2007


Darren Dale wrote:
> On Monday 19 November 2007 04:13:33 pm Jon Wright wrote:
>> Hi Darren, Andy;
>>
>> There is a nice video introduction to PyTables at:
>>
>> http://www.carabos.com/videos/pytables-1-intro
>>
>> I'd be curious as to how hard it is to write a Nexus compliant hdf file
>> using PyTables.
>>
>>  > I know he has grappled with Python and Nexus in the past
>>
>> Hmm... clearly not an expert, I lost that fight. Freddie did compile the
>> python bindings for us a while back. Having gotten the executables I
>> tried again just now and am not able to get past the testcase which
>>
>> comes with them:
>>   >>> import nxpython
>>   >>> h = nxpython.nx_open("nxpython_test.nxs", nxpython.NXACC_CREATE)
> 
> Where did you get nxpython_test.nxs? It is not included in the 4.1.0 tarball, 
> nor in my svn checkout. I can import nxpython in the python interpretter, but 
> when I tried running nxpython_test.py I got a seg fault, maybe because it is 
> trying to access a nonexistent file.
> 
> Darren



I'd guess the nxpython.NXACC_CREATE means "make a new file"? For your 
segfault try running your python under gdb (not a debug build, just what 
you already have). When it bombs you usually still get a stacktrace 
which tells you which .so (or dll) to blame. PyTables looks ever more 
attractive I guess.

Cheers,

Jon


eg:

C:\Python24\Lib\site-packages\nxpython> dir

30/07/2007  15:13           187,565 libnxpython.dll
30/07/2007  15:13             3,963 nxpython.py
30/07/2007  15:13               373 nxpython_test.py
19/11/2007  21:17             2,502 nxpython_test.nxs
30/07/2007  15:13           187,565 libnxpython.pyd
19/11/2007  21:07             3,875 nxpython.pyc

C:\Python24\Lib\site-packages\nxpython>\Python24\python
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import nxpython
 >>> h = nxpython.nx_open("another_new_file.nxs", nxpython.NXACC_CREATE)
 >>> nxpython.nx_close(h)


C:\Python24\Lib\site-packages\nxpython> dir

20/11/2007  08:56             2,900 another_new_file.nxs





More information about the NeXus mailing list