Matthieu-LAURENT39 / maubot-characterai

MIT License
3 stars 0 forks source link

ModuleNotFoundError: No module named 'characterai' #6

Open kapsikkum opened 9 months ago

kapsikkum commented 9 months ago

Error inside containerised maubot (docker)

[2023-12-18 11:17:43,711] [ERROR@maubot.server] Error in handler
Traceback (most recent call last):
  File "/opt/maubot/maubot/loader/zip.py", line 216, in _load
    importer.load_module(module)
  File "/opt/maubot/maubot/lib/zipimport.py", line 280, in load_module
    exec(code, mod.__dict__)
  File "/data/plugins/com.github.Matthieu-LAURENT39.maubot-characterai-v0.2.1.mbp/cai/__init__.py", line 1, in <module>
    from .cai import CAIBot
  File "/data/plugins/com.github.Matthieu-LAURENT39.maubot-characterai-v0.2.1.mbp/cai/cai.py", line 13, in <module>
    from characterai import PyAsyncCAI
ModuleNotFoundError: No module named 'characterai'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/opt/maubot/maubot/management/api/middleware.py", line 49, in error
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/maubot/management/api/instance.py", line 85, in update_instance
    return await _update_instance(instance, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/maubot/management/api/instance.py", line 69, in _update_instance
    await instance.update_started(data.get("started"))
  File "/opt/maubot/maubot/instance.py", line 489, in update_started
    await (self.start() if started else self.stop())
  File "/opt/maubot/maubot/instance.py", line 362, in start
    cls = await self.loader.load()
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/maubot/loader/zip.py", line 201, in load
    return self._load(reset_cache)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/maubot/loader/zip.py", line 220, in _load
    raise MaubotZipLoadError(f"Failed to load module {module}")
maubot.loader.zip.MaubotZipLoadError: Failed to load module cai
kapsikkum commented 9 months ago

When installing the characterai package with pip inside the docker container:

Traceback (most recent call last):
  File "/opt/maubot/maubot/loader/zip.py", line 216, in _load
    importer.load_module(module)
  File "/opt/maubot/maubot/lib/zipimport.py", line 280, in load_module
    exec(code, mod.__dict__)
  File "/data/plugins/com.github.Matthieu-LAURENT39.maubot-characterai-v0.2.1.mbp/cai/__init__.py", line 1, in <module>
    from .cai import CAIBot
  File "/data/plugins/com.github.Matthieu-LAURENT39.maubot-characterai-v0.2.1.mbp/cai/cai.py", line 13, in <module>
    from characterai import PyAsyncCAI
  File "/usr/lib/python3.11/site-packages/characterai/__init__.py", line 1, in <module>
    from characterai.characterai import PyCAI, PyAsyncCAI
  File "/usr/lib/python3.11/site-packages/characterai/characterai.py", line 2, in <module>
    import tls_client
  File "/usr/lib/python3.11/site-packages/tls_client/__init__.py", line 15, in <module>
    from .sessions import Session
  File "/usr/lib/python3.11/site-packages/tls_client/sessions.py", line 1, in <module>
    from .cffi import request, freeMemory
  File "/usr/lib/python3.11/site-packages/tls_client/cffi.py", line 20, in <module>
    library = ctypes.cdll.LoadLibrary(f'{root_dir}/dependencies/tls-client{file_ext}')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ctypes/__init__.py", line 454, in LoadLibrary
    return self._dlltype(name)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: Error loading shared library libresolv.so.2: No such file or directory (needed by /usr/lib/python3.11/site-packages/tls_client/dependencies/tls-client-x86.so)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/maubot/maubot/management/api/middleware.py", line 49, in error
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/maubot/management/api/instance.py", line 85, in update_instance
    return await _update_instance(instance, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/maubot/management/api/instance.py", line 69, in _update_instance
    await instance.update_started(data.get("started"))
  File "/opt/maubot/maubot/instance.py", line 489, in update_started
    await (self.start() if started else self.stop())
  File "/opt/maubot/maubot/instance.py", line 362, in start
    cls = await self.loader.load()
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/maubot/loader/zip.py", line 201, in load
    return self._load(reset_cache)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/maubot/loader/zip.py", line 220, in _load
    raise MaubotZipLoadError(f"Failed to load module {module}")
maubot.loader.zip.MaubotZipLoadError: Failed to load module cai
Matthieu-LAURENT39 commented 9 months ago

Did you install the characterai package? Maubot doesn't automatically install requirements yet

kapsikkum commented 9 months ago

you cannot install pip packages inside a docker container

Matthieu-LAURENT39 commented 8 months ago

You can with the python docker image

HWiese1980 commented 5 months ago

I installed it locally but am getting the following error message instead:

Traceback (most recent call last):
  File "/Users/user/matrix/maubot/lib/python3.12/site-packages/maubot/loader/zip.py", line 216, in _load
    importer.load_module(module)
  File "/Users/user/matrix/maubot/lib/python3.12/site-packages/maubot/lib/zipimport.py", line 280, in load_module
    exec(code, mod.__dict__)
  File "/Users/user/matrix/maubot/plugins/com.github.Matthieu-LAURENT39.maubot-characterai-v0.2.1.mbp/cai/__init__.py", line 1, in <module>
    from .cai import CAIBot
  File "/Users/user/matrix/maubot/plugins/com.github.Matthieu-LAURENT39.maubot-characterai-v0.2.1.mbp/cai/cai.py", line 13, in <module>
    from characterai import PyAsyncCAI
ImportError: cannot import name 'PyAsyncCAI' from 'characterai' (/Users/user/matrix/maubot/lib/python3.12/site-packages/characterai/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/matrix/maubot/lib/python3.12/site-packages/maubot/management/api/middleware.py", line 49, in error
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/matrix/maubot/lib/python3.12/site-packages/maubot/management/api/instance.py", line 85, in update_instance
    return await _update_instance(instance, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/matrix/maubot/lib/python3.12/site-packages/maubot/management/api/instance.py", line 69, in _update_instance
    await instance.update_started(data.get("started"))
  File "/Users/user/matrix/maubot/lib/python3.12/site-packages/maubot/instance.py", line 489, in update_started
    await (self.start() if started else self.stop())
  File "/Users/user/matrix/maubot/lib/python3.12/site-packages/maubot/instance.py", line 362, in start
    cls = await self.loader.load()
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/matrix/maubot/lib/python3.12/site-packages/maubot/loader/zip.py", line 201, in load
    return self._load(reset_cache)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/matrix/maubot/lib/python3.12/site-packages/maubot/loader/zip.py", line 220, in _load
    raise MaubotZipLoadError(f"Failed to load module {module}")
maubot.loader.zip.MaubotZipLoadError: Failed to load module cai
icewyvrn commented 3 months ago

same problem

raymand211092 commented 1 month ago

Same error and package is installed