MeteoSwiss-APN / serialbox

Data serialization library and tools for C/C++ and Fortran
BSD 2-Clause "Simplified" License
2 stars 6 forks source link

ImportError: The serialization library could not be found #76

Closed adamryczkowski closed 7 years ago

adamryczkowski commented 7 years ago

I have an error with the current (just cloned) Serialbox and Python 3.5. I have a serialized fields in the tmp-adam-dwarf0b/build folder with filenames: dwarfs.json, dwarfs_u3.dat and dwarfs_x.dat. Now I want to inspect the fields with the following Python code:

adam@adam-g551jm:/home … pos/serialbox/python$ ipython3
Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from serialbox import Serializer

In [2]: datapath='/home/Adama-docs/Adam/MyDocs/praca/IMGW/dev/tmp-adam-dwarf0b/build'

In [3]: ser = Serializer(datapath,'dwarfs')
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-f07d4f93c8ff> in <module>()
----> 1 ser = Serializer(datapath,'dwarfs')

/home/Adama-docs/Adam/MyDocs/praca/IMGW/repos/serialbox/python/serialbox/Serializer.py in __init__(self, directory, prefix, openmode)
     92             raise ValueError("Only reads are supported at the moment")
     93 
---> 94         from .serialization import Serializer
     95         self.serializer = Serializer(directory, prefix, openmode)
     96         fnames = self.serializer.fieldnames

/home/Adama-docs/Adam/MyDocs/praca/IMGW/repos/serialbox/python/serialbox/serialization.py in <module>()
     45 
     46 if wrapper is None:
---> 47     raise ImportError("The serialization library could not be found {dirs}".format(dirs=dirs))
     48 
     49 

ImportError: The serialization library could not be found ('/home/Adama-docs/Adam/MyDocs/praca/IMGW/repos/serialbox/python/serialbox', '/home/Adama-docs/Adam/MyDocs/praca/IMGW/repos/serialbox/python/serialbox/../build/src/wrapper', '.')

Why it throws the error? What can I do?

pspoerri commented 7 years ago

It cannot find the serialbox c-library. You will have to set PYTHONPATH to your python subfolder in your serialbox installation directory.

Example:

export PYTHONPATH=your_serialbox_install_path/python
ipython
....

We are also discussing this in the README.

adamryczkowski commented 7 years ago

Problem solved.