1stvamp / hippybot

Hipchat.com bot written in Python with a simple plugin API
Other
95 stars 42 forks source link

Plugins not loading: ImportError: No module named hello_world #8

Closed medoix closed 11 years ago

medoix commented 12 years ago

I am trying to write a plugin for hippybot but i cannot seem to even get the basic hello_world sample plugin loaded.

I created a file hippybot/plugins/hello_world.py and added the content in the README, i then added the line hippybot.plugins.hello_world to the config (corectly indented) and then went to start the bot and it spits out an error from bot.py and lazy_reload.py saying "ImportError: No module named hello_world" i tried writing my own also and i get the same issue, as soon as i remove this plugin from the config and just leave the defaults it works great.

Any ideas?

1stvamp commented 12 years ago

@medoix could you paste in the full output? Can't replicate on my machine.

1stvamp commented 12 years ago

@medoix also your full hippybot.conf might be handy too, ta!

medoix commented 12 years ago

Error:

(hippybot)steven@server:/data/programs/hippybot/hippybot$ hippybot -c hippybot.conf
ERROR: No module named hello_world
Traceback (most recent call last):
  File "/data/programs/hippybot/local/lib/python2.7/site-packages/hippybot-1.0.0-py2.7.egg/hippybot/bot.py", line 256, in run
    bot = HippyBot(self.config._sections)
  File "/data/programs/hippybot/local/lib/python2.7/site-packages/hippybot-1.0.0-py2.7.egg/hippybot/bot.py", line 69, in __init__
    self.load_plugins()
  File "/data/programs/hippybot/local/lib/python2.7/site-packages/hippybot-1.0.0-py2.7.egg/hippybot/bot.py", line 190, in load_plugins
    module = do_import(path)
  File "/data/programs/hippybot/local/lib/python2.7/site-packages/hippybot-1.0.0-py2.7.egg/hippybot/bot.py", line 26, in do_import
    mod = __import__(name)
  File "/data/programs/hippybot/local/lib/python2.7/site-packages/lazy_reload.py", line 83, in _lazy_reload_import
    m = _real_import(name, globals, locals, fromlist, level)
ImportError: No module named hello_world
medoix commented 12 years ago

Conf:

[connection]
username = 22974_157931
password = PASSWORD
nickname = HC Bot
channels = Test
           Infrastructure
[plugins]
load = hcbot.plugins.hello_world
       hcbot.plugins.mexican_wave
[hipchat]
api_auth_token = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
respond_to_all = true
medoix commented 12 years ago

Might be worth noting that i am running this using virtualenv on ubuntu it works if i change hello_world to rot13 so im really confused.

1stvamp commented 12 years ago

@medoix the only thing I can see that might be iffy is the fact your namespace paths in plugins.load config point to hcbot rather than hippybot if you're putting them in hippybot/plugins/ rather than in an importable module named hcbot in your PYTHON_PATH.

medoix commented 12 years ago

ahh sorry i posted the wrong config (trying different things) the correct config says hippybot in the plugin path.

1stvamp commented 12 years ago

Aha. That makes sense. Can you post the contents of hello_world.py? Only other thing the module might fail to load is if it fails to compile. I know you said it was just the contents of the example from the readme, but I just copied it in tried it myself and it was fine.

medoix commented 12 years ago

hello_world.py located in /data/programs/hippbot/hippybot/hippybot/plugins

# hello_world.py
from hippybot.decorators import botcmd, directcmd
class Plugin(object):
    global_commands = ['hello_world']
    command_aliases = {'hi!': 'hello'}
    @botcmd
    def hello_world(self, mess, args):
        return u'Hello world!'
    @directcmd
    def hello(self, mess, args):
        return u'Well hello there..'
1stvamp commented 12 years ago

Ah, I'd actually re-tested the class based example, however changing "hcbot" back to "hippybot":

from hippybot.decorators import directcmd

@directcmd
def hello_world(bot, mess, args):
    return u'Hello world!'

It still works. :-/

medoix commented 12 years ago

It is all hippybot now, i actually deleted everything and just started fresh, i did have it working at one point but now im testing again and it just fails to load the hello_world plugin. I have it running (not really running) on an EC2 instance if you like i can give you access but im at a loss as to what is actually happening.