reworkd / AgentGPT

🤖 Assemble, configure, and deploy autonomous AI Agents in your browser.
https://agentgpt.reworkd.ai
GNU General Public License v3.0
31.88k stars 9.25k forks source link

No module named 'langchain.globals' #1393

Open mongolu opened 1 year ago

mongolu commented 1 year ago

Please check that this issue hasn't been reported before.

Expected Behavior

not to throw error

Current behaviour

2023-11-21 08:01:55 INFO:     Stopping reloader process [1]
2023-11-21 08:04:44 INFO:     Will watch for changes in these directories: ['/app/src']
2023-11-21 08:04:44 INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
2023-11-21 08:04:44 INFO:     Started reloader process [1] using WatchFiles
2023-11-21 08:04:46 Process SpawnProcess-1:
2023-11-21 08:04:46 Traceback (most recent call last):
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
2023-11-21 08:04:46     self.run()
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/multiprocessing/process.py", line 108, in run
2023-11-21 08:04:46     self._target(*self._args, **self._kwargs)
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started
2023-11-21 08:04:46     target(sockets=sockets)
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/uvicorn/server.py", line 61, in run
2023-11-21 08:04:46     return asyncio.run(self.serve(sockets=sockets))
2023-11-21 08:04:46            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
2023-11-21 08:04:46     return runner.run(main)
2023-11-21 08:04:46            ^^^^^^^^^^^^^^^^
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
2023-11-21 08:04:46     return self._loop.run_until_complete(task)
2023-11-21 08:04:46            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-11-21 08:04:46   File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/uvicorn/server.py", line 68, in serve
2023-11-21 08:04:46     config.load()
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/uvicorn/config.py", line 473, in load
2023-11-21 08:04:46     self.loaded_app = import_from_string(self.app)
2023-11-21 08:04:46                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/uvicorn/importer.py", line 24, in import_from_string
2023-11-21 08:04:46     raise exc from None
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/uvicorn/importer.py", line 21, in import_from_string
2023-11-21 08:04:46     module = importlib.import_module(module_str)
2023-11-21 08:04:46              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
2023-11-21 08:04:46     return _bootstrap._gcd_import(name[level:], package, level)
2023-11-21 08:04:46            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-11-21 08:04:46   File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
2023-11-21 08:04:46   File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
2023-11-21 08:04:46   File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
2023-11-21 08:04:46   File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
2023-11-21 08:04:46   File "<frozen importlib._bootstrap_external>", line 940, in exec_module
2023-11-21 08:04:46   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2023-11-21 08:04:46   File "/app/src/reworkd_platform/web/application.py", line 11, in <module>
2023-11-21 08:04:46     from reworkd_platform.web.api.router import api_router
2023-11-21 08:04:46   File "/app/src/reworkd_platform/web/api/router.py", line 3, in <module>
2023-11-21 08:04:46     from reworkd_platform.web.api import agent, auth, metadata, models, monitoring
2023-11-21 08:04:46   File "/app/src/reworkd_platform/web/api/agent/__init__.py", line 2, in <module>
2023-11-21 08:04:46     from reworkd_platform.web.api.agent.views import router
2023-11-21 08:04:46   File "/app/src/reworkd_platform/web/api/agent/views.py", line 17, in <module>
2023-11-21 08:04:46     from reworkd_platform.web.api.agent.agent_service.agent_service_provider import (
2023-11-21 08:04:46   File "/app/src/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py", line 15, in <module>
2023-11-21 08:04:46     from reworkd_platform.web.api.agent.agent_service.open_ai_agent_service import (
2023-11-21 08:04:46   File "/app/src/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py", line 4, in <module>
2023-11-21 08:04:46     from lanarky.responses import StreamingResponse
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/lanarky/__init__.py", line 1, in <module>
2023-11-21 08:04:46     from .responses import StreamingResponse
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/lanarky/responses/__init__.py", line 1, in <module>
2023-11-21 08:04:46     from .streaming import StreamingResponse
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/lanarky/responses/streaming.py", line 18, in <module>
2023-11-21 08:04:46     from lanarky.callbacks import (
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/lanarky/callbacks/__init__.py", line 11, in <module>
2023-11-21 08:04:46     from .agents import *  # noqa: F401, F403
2023-11-21 08:04:46     ^^^^^^^^^^^^^^^^^^^^^
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/lanarky/callbacks/agents.py", line 10, in <module>
2023-11-21 08:04:46     from .base import AsyncLanarkyCallback
2023-11-21 08:04:46   File "/usr/local/lib/python3.11/site-packages/lanarky/callbacks/base.py", line 7, in <module>
2023-11-21 08:04:46     from langchain.globals import get_llm_cache
2023-11-21 08:04:46 ModuleNotFoundError: No module named 'langchain.globals'

Steps to reproduce

build the docker-compose

Possible solution

I don't know if it's just with me, and if yes, how can i correct this?

Which Operating Systems are you using?

Acknowledgements

hunkjun commented 1 year ago

I had the same problem

root@71987129c9f5:/app/src# pip3 list | grep langchain
langchain                  0.0.295

root@71987129c9f5:/app/src# python3
Python 3.11.4 (main, Jun 13 2023, 15:34:37) [GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import langchain
>>> import langchain.globals
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'langchain.globals'
>>>
>>>

Please upgrade langchain to 0.0.340 to solve my problem.

root@71987129c9f5:/app/src# pip3 list | grep langchain
langchain                  0.0.340
root@71987129c9f5:/app/src# python3
Python 3.11.4 (main, Jun 13 2023, 15:34:37) [GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import langchain.globals
>>>
QZH-777 commented 12 months ago

If choosing to use docker, how can I update the version of langchain in docker container? I don't know how to update it since there is no pip or conda in the docker container.

DevSam7t3 commented 12 months ago

facing the same issue. is it fixed for you??

mongolu commented 12 months ago

I connected to the docker container and did upgrade the langchain package, like this

docker exec -it platform bash
pip install langchain --upgrade

And restart the container. Now the error is gone.

Before this, langchain was Version: 0.0.295, after upgrade is Version: 0.0.344

DevSam7t3 commented 12 months ago

i did as guided and it updated the langchian and in return it gives and error: "reworkd-platform 0.1.0 requires langchain<0.0.296,>=0.0.295, but you have langchain 0.0.344 which is incompatible."

mongolu commented 12 months ago

this is like it's expected because it's listed like this in platform/pyproject.toml

huaji23 commented 11 months ago

+1

DevSam7t3 commented 11 months ago

working fine. ❤️

adrian-valente commented 11 months ago

Up this thread, it works fine by updating the .toml, would it be relevant to turn this into a PR?

generalistcodes commented 11 months ago

Fix it by updating the version of langchain = "^0.0.295" to langchain = "^0.0.344" pyproject.toml

After that run:

adrian-valente commented 11 months ago

This is actually fixed by PR #1424 that is waiting to be merged

pythonmandev commented 8 months ago

I install AgentGPT in local server but docker,my langchain version: pip list| grep langc langchain 0.1.11 langchain-community 0.0.27 langchain-core 0.1.30 langchain-text-splitters 0.0.1

ohmycode commented 5 months ago

After deploying I had the same problem

following @mongolu advice

I connected to the docker container and did upgrade the langchain package, like this

docker exec -it platform bash
pip install langchain --upgrade

and then doing the same with

pip install langchain_community --upgrade

fixed it for me

Dinuda commented 5 months ago

worth a pr

yucelz commented 3 months ago

The primary issue pertains to lanarky version [v0.7.17]. A review of their release notes will reveal the same exception, which can be found at https://github.com/ajndkr/lanarky/releases. To resolve this, please update your lanarky version to 0.8.0 and python = ">=3.11,<3.12" in your pyproject.toml file.

grebnebo commented 2 weeks ago

For eleven month you cannot fix this bug? steps to reproduce

  1. git clone AgentGPT repo
  2. setup.sh (two different machines with ubuntu 24.04)
  3. No module named 'langchain.globals' if you will update to version langchain==0.0.344 there is another error: platform | ImportError: cannot import name '_signature' from 'langchain_community.chat_models.baichuan' (/usr/local/lib/python3.11/site-packages/langchain_community/chat_models/baichuan.py)