fbradyirl / webex_bot

Python package for a Webex Bot based on websockets.
MIT License
72 stars 46 forks source link

ModuleNotFoundError: No module named 'imp' #44

Open Schenk0 opened 1 year ago

Schenk0 commented 1 year ago

Webex Bot version: ??? newest (just ran pipenv install webex_bot) Python version: 3.12.0 Operating System: Windows 10

So I'm trying to get a simple Webex bot running and I am following this tutorial: https://www.youtube.com/watch?v=pC_hj2-czlk but every time I run python app.py (the driver script) I get the ModuleNotFoundError: No module named 'imp' here is all of my code:

app.py:

from gpt import gpt
from webex_bot.webex_bot import WebexBot

#Create a Bot Object
bot = WebexBot("MY_WebEx_Bot_Access_Token")

#Clear default help command
bot.commands.clear()

#Add new commands for the bot to listen out for.
bot.add_command(gpt())

#Set new command as default
bot.help_command = gpt()

#Call `run` for the bot to wait for incoming messages.
bot.run()

gpt.py:

from webex_bot.models.response import Response

class gpt(Command):

    def __init__(self):
        super().__init__()

    def execute(self, message, attachment_actions, activity):

        return "Hello World!"

What am I doing wrong?

Here is the full error:

PS C:\Users\Bruger\Desktop\WebExBotTest2> python app.py
Traceback (most recent call last):
  File "C:\Users\Bruger\Desktop\WebExBotTest2\app.py", line 1, in <module>
    from gpt import gpt
  File "C:\Users\Bruger\Desktop\WebExBotTest2\gpt.py", line 3, in <module>
    from webex_bot.models.response import Response
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webex_bot\models\response.py", line 3, in <module>
    from webexteamssdk.models.cards import AdaptiveCard
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webexteamssdk\__init__.py", line 40, in <module>
    from .api import WebexTeamsAPI
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webexteamssdk\api\__init__.py", line 33, in <module>
    from webexteamssdk.models.immutable import immutable_data_factory
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webexteamssdk\models\immutable.py", line 42, in <module>
    from webexteamssdk.utils import json_dict
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\webexteamssdk\utils.py", line 33, in <module>
    from future import standard_library
  File "C:\Users\Bruger\.virtualenvs\WebExBotTest2-GkhwRhsf\Lib\site-packages\future\standard_library\__init__.py", line 65, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'
gconklin commented 1 year ago

Hi @Schenk0 - you're using Python 3.12, which removed the imp lib (https://docs.python.org/3.12/whatsnew/3.12.html#imp)

There is an open issue to address this in the python-future library (https://github.com/PythonCharmers/python-future/issues/488)

For now I would say use 3.11

Schenk0 commented 1 year ago

yeah, I realized that, but now I can't get the python to show up, but that's probably not an issue to discuss here...

And thanks for the quick response : D

gconklin commented 1 year ago

Hm, assuming the code you posted above has not changed much, it may be related to issue #41. I tried your code above with my bot token and it did work for me.

Schenk0 commented 1 year ago

So the issue can be

  1. I'm behind a proxy
  2. ???

I have no idea what fixes I can try, I just created a new bot still have the same issue. One note I have is that I can't message the bot directly at first. It says it can't find any user with that username. I have to add it to a space, then after that send it a direct message, don't know if that has anything to do with it?