opencog / link-grammar

The CMU Link Grammar natural language parser
GNU Lesser General Public License v2.1
388 stars 119 forks source link

python not working on ubuntu 14.04 #730

Closed linas closed 6 years ago

linas commented 6 years ago

I have a laptop here, Ubuntu 14.04, with minimal install and setup, and I am getting this:

Traceback (most recent call last):
  File "./example.py", line 9, in <module>
    print ("Version:", clg.linkgrammar_get_version())
AttributeError: 'module' object has no attribute 'linkgrammar_get_version'

Running things manually gives:

python
Python 2.7.6 (default, Nov 23 2017, 15:49:48) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from linkgrammar import Sentence, ParseOptions, Dictionary
>>> 
>>> sent = Sentence("This is a simple sentence.", Dictionary(), ParseOptions())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/linkgrammar/linkgrammar.py", line 329, in __init__
    self._obj = clg.dictionary_create_lang(lang)
AttributeError: 'module' object has no attribute 'dictionary_create_lang'
>>> 

The config is

link-grammar-5.4.4  build configuration settings

    prefix:                         /usr/local
    C compiler:                     gcc  -D_DEFAULT_SOURCE -std=c11 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -D_ISOC11_SOURCE -g -O2 -O3
    C++ compiler:                   g++  -D_DEFAULT_SOURCE -std=c++11 -g -O2 -O3 -Wall
    Regex library:                  
    Error handler per-thread:       yes
    Editline command-line history:  yes
    UTF8 editline support:          no
    Java libraries:                 yes
    Java interfaces:                yes
    Swig interfaces generator:      no
    Perl interfaces:                no
    Perl install location:          
    Python2 interfaces:             2.7
    Python3 interfaces:             no
    ASpell spell checker:           no
    HunSpell spell checker:         no
    HunSpell dictionary location:   
    Boolean SAT parser:             yes (using the bundled minisat library)
    SQLite-backed dictionary:       yes
    Viterbi algorithm parser:       
    Corpus statistics database:     no
    RegEx tokenizer:                no
linas commented 6 years ago

So,

nm /usr/local/lib/python2.7/dist-packages/linkgrammar/_clink*so 

indicates that the so is nearly empty, viz, the bindings were not actually built ... the so only contains the minimal stuff needed for an so.

linas commented 6 years ago

Seems that lg_python_wrap.cc is empty ...

linas commented 6 years ago

This is apparently because I do not have swig installed, and I am building from git.

linas commented 6 years ago

Yeah. User error. Our Makefile.am does not warn when SWIG is missing, and the SWIG-generated files are also missing. This is leds to confusion, when compiling from git.

linas commented 6 years ago

Fixed by #732