ananas icon indicating copy to clipboard operation
ananas copied to clipboard

TypeError: 'module' object is not callable

Open alx opened this issue 6 years ago • 3 comments

https://github.com/chr-1x/ananas/blob/e4625a3da193fa1c77119edb68d4ee18dcbc56ca/ananas/run.py#L43

I've had an issue with this line, and had to change it to the following one in order to make my project working:

exec("from {0}.{1} import {1}; bots.append({1}('{2}', name='{3}', interactive={4}, verbose={5}))"

I've got a bot python file in custom/ArchiveBot.py and my config.cfg contains the following class: class = custom.ArchiveBot

With the current line exec("from {0} import {1}, it return the following error:

/home/alx/.local/bin/ananas: fatal exception loading bot archive_bot: TypeError("'module' object is not callable",)
Traceback (most recent call last):
  File "/home/alx/.local/lib/python3.6/site-packages/ananas/run.py", line 44, in main
    .format(module, botclass, args.config, bot, args.interactive, args.verbose))
  File "<string>", line 3, in <module>
TypeError: 'module' object is not callable

alx avatar Jun 25 '19 22:06 alx

I'm new to python, my project file structure is probably wrong

alx avatar Jun 25 '19 22:06 alx

This could be a python version issue, I think I tested on 3.5. I'll look into it this weekend maybe.

chr-1x avatar Jul 04 '19 02:07 chr-1x

I know I'm almost a year late to this, but the correct spec for your class in this case would be custom.ArchiveBot.ArchiveBot. With the former, it's trying to use the module object as your bot class. With the one I've provided, it should probably work.

MineRobber9000 avatar Mar 18 '20 05:03 MineRobber9000