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

AttributeError: module 'langchain' has no attribute 'verbose' #4164

Closed
3 of 14 tasks
MoAmrYehia opened this issue May 5, 2023 · 22 comments
Closed
3 of 14 tasks

AttributeError: module 'langchain' has no attribute 'verbose' #4164

MoAmrYehia opened this issue May 5, 2023 · 22 comments

Comments

@MoAmrYehia
Copy link

MoAmrYehia commented May 5, 2023

System Info

langchain==0.0.157

Who can help?

No response

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

When I try to run llm = OpenAI(temperature=0)

AttributeError                            Traceback (most recent call last)
Cell In[11], line 1
----> 1 llm = OpenAI(temperature=0)
      3 # Initialize a ConversationBufferMemory object to store the chat history
      4 memory = ConversationBufferMemory(memory_key="chat_history") 

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/pydantic/main.py:339, in pydantic.main.BaseModel.__init__()

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/pydantic/main.py:1066, in pydantic.main.validate_model()

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/pydantic/fields.py:439, in pydantic.fields.ModelField.get_default()

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/langchain/llms/base.py:26, in _get_verbosity()
     25 def _get_verbosity() -> bool:
---> 26     return langchain.verbose

AttributeError: module 'langchain' has no attribute 'verbose'

Expected behavior

Don't get the error

@clauslang
Copy link

Same issue here with Anaconda in a jupyter notebook on sagemaker, langchain==0.0.158, python3.9, with this simple custom LLM example: https://python.langchain.com/en/latest/modules/models/llms/examples/custom_llm.html

@yinyijie
Copy link

yinyijie commented May 5, 2023

Same error here with langchain==0.0.158, python3.9. need to fix it asap.

@marcelocerchiKiron
Copy link

Hello, same error with langchain==0.0.159, python 3.9.12

@yetilfx
Copy link

yetilfx commented May 5, 2023

Hello, same error with langchain==0.0.158, python 3.9.11

@fjun99
Copy link

fjun99 commented May 6, 2023

same , langchain==0.0.160

@fjun99
Copy link

fjun99 commented May 6, 2023

call with azure openai broken(RetrievalQA, resource not found). when use langchain==0.0.150, everything is ok.

@vamsiramakrishnan
Copy link

same, langchain ==0.0.160 with python 3.8.10

@cjflanagan
Copy link

Hello, same error with langchain==0.0.160, python 3.10.11

@wafflecomposite
Copy link

Some kind of race condition bug?

Seems to be fixable by explicitly

import langchain
langchain.verbose = False

before trying to initialize llm.

@MoAmrYehia
Copy link
Author

MoAmrYehia commented May 8, 2023

@wafflecomposite This solution worked for me. Thanks!

@iamulya
Copy link

iamulya commented Jul 21, 2023

This issue seems to have resurfaced in version 0.0.234 of langchain. The suggested solution in the issue works only temporarily, meaning the issue popped up after some time again.

@urbanscribe
Copy link

Some kind of race condition bug?

Seems to be fixable by explicitly

import langchain
langchain.verbose = False

before trying to initialize llm.

this did not work for me.

@ryanholtschneider2
Copy link

Getting this error in 0.0.299 as well

@jorrgme
Copy link

jorrgme commented Oct 6, 2023

Just in case someone gets this error now, the only thing that worked for me was updating langchain's version. In my case I'm using poetry as my package manager and did:

poetry update langchain

If you're using pip just use:

pip install --upgrade langchain

I tried using the langchain.verbose = False workaround that was mentioned here but it ended up triggering the same error later.

@fabilix
Copy link

fabilix commented Nov 9, 2023

This issue still appears in the latest version (0.0.332). Is there a known solution?

@wafflecomposite
Copy link

My langchain.verbose = False "solution" is no longer relevant since #11311

@fabilix check out a suggestions on this issue #9854
If that doesn't help, add a comment there too. Apparently it's still an unsolved problem.

@Lakmal-Fernando
Copy link

I also faced this issue. In my case it was my folder structure messing with the imports. I had a folder called langchain within my project. After I renamed it it worked fine.

@lestat2023
Copy link

I also faced this issue. In my case it was my folder structure messing with the imports. I had a folder called langchain within my project. After I renamed it it worked fine.

great!rename can solve

@WANGHEMING-BUPT
Copy link

我也遇到过这个问题。就我而言,是我的文件夹结构弄乱了导入。我在我的项目中有一个文件夹。重命名后,它工作正常。langchain

good job bro, i have solved the question due to your reply

@Hardy0611
Copy link

I also faced this issue. In my case it was my folder structure messing with the imports. I had a folder called langchain within my project. After I renamed it it worked fine.

it works, I can't belive the reason is this stupid LOL.

@jy1989
Copy link

jy1989 commented May 11, 2024

For me, I had a file named langchain.py make this error.

change the name it seems ok -__-

@cauchycai
Copy link

I named my python file "langchain.py". When I ran it using "python langchain.py", I get this error. After I renamed the "langchain.py" to some other name, the error is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests