I had a similar problem, but using python 3 on Mac OS 10.7. The following worked for me so hopefully it might help you out a bit:
My error, similar to yours:
>>> import pyfann
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyfann/__init__.py", line 4, in <module>
import libfann
ImportError: No module named 'libfann'
So, I have a look around inside the file __init__.py
, it looks like this:
#
# Fast Artificial Neural Network library for Python
#
import libfann
__all__ = [
'libfann'
]
For some reason it cannot find libfann, but libfann is in the exact same folder as __init__.py
. Maybe we can edit __init__.py
and tell it where libfann is:
#
# Fast Artificial Neural Network library for Python
#
# import imp so we can load modules ourselves rather than through import magic
import imp
# try to load libfann, giving the exact path of where libfann resides
imp.load_source ('libfann','/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyfann/libfann.py')
Then try and run one of the examples:
python3 ~/Downloads/FANN-2.2.0-Source/python/examples/simple_train.py
FANN Error 1: Unable to open configuration file "../../examples/xor.data" for reading.
FANN Error 2: Unable to open configuration file "nets/xor_float.net" for writing.
I had to open simple_train.py and enter the full paths where it complains that it can't find the configuration files, but now it runs ok:
python3 ~/Downloads/FANN-2.2.0-Source/python/examples/simple_train.py
Max epochs 100000. Desired error: 0.0001000000.
Epochs 1. Current error: 0.2500073016. Bit fail 4.
Epochs 39. Current error: 0.0000279390. Bit fail 0.