Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'langchain.globals' #1393

Open
6 of 10 tasks
mongolu opened this issue Nov 21, 2023 · 16 comments
Open
6 of 10 tasks

No module named 'langchain.globals' #1393

mongolu opened this issue Nov 21, 2023 · 16 comments
Labels
bug Something isn't working

Comments

@mongolu
Copy link

mongolu commented Nov 21, 2023

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

  • I searched previous Bug Reports didn't find any similar reports.

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?

  • Android
  • iPhone/iPad
  • Linux
  • macOS
  • Windows

Acknowledgements

  • My issue title is concise, descriptive, and in title casing.
  • I have searched the existing issues to make sure this bug has not been reported yet.
  • I am using the latest version of AgentGPT.
  • I have provided enough information for the maintainers to reproduce and diagnose the issue.
@mongolu mongolu added the bug Something isn't working label Nov 21, 2023
@hunkjun
Copy link

hunkjun commented Nov 23, 2023

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
Copy link

QZH-777 commented Nov 29, 2023

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
Copy link

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

@mongolu
Copy link
Author

mongolu commented Dec 1, 2023

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
Copy link

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
Copy link
Author

mongolu commented Dec 1, 2023

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

@huaji23
Copy link

huaji23 commented Dec 4, 2023

+1

@DevSam7t3
Copy link

working fine. ❤️

@adrian-valente
Copy link

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

@generalistcodes
Copy link

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

After that run:

  • docker-compose build platform <-- container name of API
  • docker-compose up -d

@adrian-valente
Copy link

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

LordWestcott added a commit to LordWestcott/AgentGPT that referenced this issue Dec 31, 2023
This was causing a build issue for myself and a few others. Please see:
reworkd#1393
@pythonmandev
Copy link

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
Copy link

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
Copy link

Dinuda commented Jun 12, 2024

worth a pr

@yucelz
Copy link

yucelz commented Aug 27, 2024

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
Copy link

grebnebo commented Nov 6, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests