Menu

Knowledge base not found

Help
Mr.SpOOn
2008-09-10
2013-05-17
  • Mr.SpOOn

    Mr.SpOOn - 2008-09-10

    Hi,
    I'm starting to learn using Pyke. I almost read everything in the documentation and I'm trying to re-create the family_relations example.

    I have these files:

    # family.kfb
    son_of(michael, bruce)
    son_of(bruce, thomas)
    son_of(thomas, frederik)
    son_of(frederik, hiram)

    _______________________

    # fc_examples.krb
    son_of
        foreach
            family.son_of($son, $father)
        assert
            family.father_son($father, $son, ())

    grand_father_son
        foreach
            family.father_son($father, $grand_son, ())
            family.father_son($grand_father, $father, ())
        assert
            family.father_son($grand_father, $grand_son, (grand))

    great_grand_father_son
        foreach
            family.father_son($father, $gg_son, ())
            family.father_son($gg_father, $father, ($prefix1, *$rest_prefixes))
        assert
            family.father_son($gg_father, $gg_son, (great, $prefix1, *$rest_prefixes))

    _______________________

    # test.py

    from pyke import knowledge_engine

    my_engine = knowledge_engine.engine('.')
    my_engine.activate('fc_example')

    When I run test.py I get this error:

    writing ./compiled_krb/fc_example_fc.py
    Traceback (most recent call last):
      File "test.py", line 9, in <module>
        my_engine.activate('fc_example')
      File "build/bdist.linux-i686/egg/pyke/knowledge_engine.py", line 134, in activate
      File "build/bdist.linux-i686/egg/pyke/rule_base.py", line 107, in activate
      File "build/bdist.linux-i686/egg/pyke/rule_base.py", line 91, in register_fc_rules
      File "build/bdist.linux-i686/egg/pyke/fc_rule.py", line 79, in register_rule
      File "build/bdist.linux-i686/egg/pyke/knowledge_engine.py", line 97, in get_kb
    KeyError: 'knowledge_base family not found'

    What am I doing wrong?
    Thanks for your help.

    Bye,
    Carlo

     
    • Bruce Frederiksen

      There are two possible problems. 

      But first, I want to just let you know that the documentation was overhauled significantly in the new 0.4 release.  If you are reading the documentation from a prior release, I would strongly recommend that you switch to the 0.4 documentation.

      OK, back to your problem.  The most likely cause of your problem is that you are running an older version of Pyke.  To use the new .kfb files, you need version 0.4.  To check this:

      >>> import pyke
      >>> pyke.version
      '0.4'

      If that's not it, then you must have the family.kfb file in a different location than the fc_example.krb file so that Pyke isn't finding it.

      Let me know if neither of these is the problem.

      I also want to point out that the subversion version of pyke is currently broken, so take the 0.4 release version (such as by using easy_install).

      -bruce

       
    • Mr.SpOOn

      Mr.SpOOn - 2008-09-13

      Well, I checked and I still have the older Pyke version. So I think you're right about the problem. Anyway, I tried to run the same example, but from the shell and it worked. Is it normal?

      Now I'd like to install the new version. I have a problem with easy_install. When I do:

      sudo easy_install-2.5 pyke

      I get this error:

      Processing pyke
      error: Couldn't find a setup script in pyke

      I've tried installing again easy_install, but it's the same.
      What can I do?

       
    • Mr.SpOOn

      Mr.SpOOn - 2008-09-13

      Sorry for double posting, but I just solved the problem.

      It worked with:

      sudo easy_install-2.5 pyke-0.4.tar.gz

      Anyway, I am curious to know what was the problem with:

      sudo easy_install-2.5 pyke

      inside the directory.

      I removed the egg file of the version 0.3, from the site-packages directory. Are there other files to remove?

      Anyway, thanks.

       
      • Bruce Frederiksen

        I'm not sure what the problem was.  If you have an old version of a program, you can run:

        easy_install --upgrade pyke

        and it should fix you up.  This does not delete the old version, just takes it off of the python path.  Just delete the old .egg file in the site-packages directory.

        I tried installing pyke from scratch (no previous version installed) with easy_install and it worked fine.

        Trying "easy_install pyke" with pyke 0.3 already installed (by easy_install), it doesn't seem to do anything, just says that pyke is already installed.  (But doesn't generate an error either).

        Then doing "easy_install --upgrade pyke" installs the 0.4 release, putting 0.4 on the python path rather than 0.3 but does not delete the 0.3 egg file.

        So I don't see any problem with the pyke installation.

        Sounds like you should be OK now!

         

Log in to post a comment.