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
Seeing an error ModuleNotFoundError: No module named 'langchain.globals' #13064
Comments
🤖 Hello @amrit2cisco, Nice to meet you! I'm here to assist you with your issues related to LangChain. I'm a bot, designed to help solve bugs, answer questions, and guide you to become a contributor while we wait for a human maintainer. Let's get started on this! Based on the information provided, it seems like the 'langchain.globals' module is not directly importable in the LangChain version "^0.0.278". This is likely because the 'langchain.globals' module is not imported at the top level of the 'init.py' file. Instead, it's imported within the 'getattr' function, which is a special Python function that is called when trying to access a non-existent attribute. To resolve this issue, you should replace any direct imports of 'langchain.globals' with the appropriate function calls to 'langchain.globals.set_verbose()', 'langchain.globals.get_verbose()', 'langchain.globals.set_debug()', 'langchain.globals.get_debug()', 'langchain.globals.set_llm_cache()', or 'langchain.globals.get_llm_cache()', as suggested by the warning messages. Here's an example of how you can use these functions: from langchain import globals
# Set verbose
globals.set_verbose(True)
# Get verbose
verbose = globals.get_verbose()
# Set debug
globals.set_debug(True)
# Get debug
debug = globals.get_debug()
# Set llm_cache
globals.set_llm_cache(True)
# Get llm_cache
llm_cache = globals.get_llm_cache() Please note that these functions should be used instead of directly accessing the 'verbose', 'debug', and 'llm_cache' attributes. For more information, you can refer to the following files in the LangChain repository: I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Did what the bot said and I got the following error: ImportError: cannot import name 'globals' from partially initialized module 'langchain' (most likely due to a circular import) (SOMAEPATH\langchain.py) |
Found the comment here and found that I'm not a smart man either.😅 |
System Info
LangChain version pinned to "^0.0.278" (using Poetry)
Python 3.11.5
Other modules from langchain (such as langchain.cache and langchain.chains) are imported within the same file in the application code and are able to be found. Only the
langchain.globals
module is not being recognizedWho can help?
No response
Information
Related Components
Reproduction
Import langchain.globals
Error happens on application startup
Expected behavior
Expected to be able to find the module, as langchain's other module's are able to be found by the same application code
The text was updated successfully, but these errors were encountered: