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 while importing langchain_core. prompts , AttributeError: module 'requests' has no attribute 'auth' #29208

Open
5 tasks done
dakshsinghal2003 opened this issue Jan 14, 2025 · 1 comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: core Related to langchain-core investigate Flagged for investigation.

Comments

@dakshsinghal2003
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

from langchain_core.prompts  import ChatPromptTemplate
from langchain_core.prompts.chat  import MessagesPlaceholder
from langchain_core.messages import AIMessage,HumanMessage,SystemMessage
from langchain_core.output_parsers import StrOutputParser
from langchain_ollama import ChatOllama

Error Message and Stack Trace (if applicable)


AttributeError Traceback (most recent call last)
Cell In[15], line 1
----> 1 from langchain_core.prompts import ChatPromptTemplate
2 from langchain_core.prompts.chat import MessagesPlaceholder
3 from langchain_core.messages import AIMessage,HumanMessage,SystemMessage

File d:\BTP Work\virtual_environment\Lib\site-packages\langchain_core\prompts_init_.py:28
1 """Prompt is the input to the model.
2
3 Prompt is often constructed
(...)
25
26 """ # noqa: E501
---> 28 from langchain_core.prompts.base import (
29 BasePromptTemplate,
30 aformat_document,
31 format_document,
32 )
33 from langchain_core.prompts.chat import (
34 AIMessagePromptTemplate,
35 BaseChatPromptTemplate,
(...)
40 SystemMessagePromptTemplate,
41 )
42 from langchain_core.prompts.few_shot import (
43 FewShotChatMessagePromptTemplate,
44 FewShotPromptTemplate,
45 )

File d:\BTP Work\virtual_environment\Lib\site-packages\langchain_core\prompts\base.py:26
24 from langchain_core.exceptions import ErrorCode, create_message
25 from langchain_core.load import dumpd
---> 26 from langchain_core.output_parsers.base import BaseOutputParser
27 from langchain_core.prompt_values import (
28 ChatPromptValueConcrete,
29 PromptValue,
30 StringPromptValue,
31 )
32 from langchain_core.runnables import RunnableConfig, RunnableSerializable

File d:\BTP Work\virtual_environment\Lib\site-packages\langchain_core\output_parsers_init_.py:16
1 """OutputParser classes parse the output of an LLM call.
2
3 Class hierarchy:
(...)
13 Serializable, Generation, PromptValue
14 """ # noqa: E501
---> 16 from langchain_core.output_parsers.base import (
17 BaseGenerationOutputParser,
18 BaseLLMOutputParser,
19 BaseOutputParser,
20 )
21 from langchain_core.output_parsers.json import JsonOutputParser, SimpleJsonOutputParser
22 from langchain_core.output_parsers.list import (
23 CommaSeparatedListOutputParser,
24 ListOutputParser,
25 MarkdownListOutputParser,
26 NumberedListOutputParser,
27 )

File d:\BTP Work\virtual_environment\Lib\site-packages\langchain_core\output_parsers\base.py:16
5 from typing import (
6 TYPE_CHECKING,
7 Any,
(...)
11 Union,
12 )
14 from typing_extensions import override
---> 16 from langchain_core.language_models import LanguageModelOutput
17 from langchain_core.messages import AnyMessage, BaseMessage
18 from langchain_core.outputs import ChatGeneration, Generation

File d:\BTP Work\virtual_environment\Lib\site-packages\langchain_core\language_models_init_.py:50
1 """Language Model is a type of model that can generate text or complete
2 text prompts.
3
(...)
39
40 """ # noqa: E501
42 from langchain_core.language_models.base import (
43 BaseLanguageModel,
44 LangSmithParams,
(...)
48 get_tokenizer,
49 )
---> 50 from langchain_core.language_models.chat_models import BaseChatModel, SimpleChatModel
51 from langchain_core.language_models.fake import FakeListLLM, FakeStreamingListLLM
52 from langchain_core.language_models.fake_chat_models import (
53 FakeListChatModel,
54 FakeMessagesListChatModel,
55 GenericFakeChatModel,
56 ParrotFakeChatModel,
57 )

File d:\BTP Work\virtual_environment\Lib\site-packages\langchain_core\language_models\chat_models.py:33
31 from langchain_core._api import deprecated
32 from langchain_core.caches import BaseCache
---> 33 from langchain_core.callbacks import (
34 AsyncCallbackManager,
35 AsyncCallbackManagerForLLMRun,
36 BaseCallbackManager,
37 CallbackManager,
38 CallbackManagerForLLMRun,
39 Callbacks,
40 )
41 from langchain_core.globals import get_llm_cache
42 from langchain_core.language_models.base import (
43 BaseLanguageModel,
44 LangSmithParams,
45 LanguageModelInput,
46 )

File d:\BTP Work\virtual_environment\Lib\site-packages\langchain_core\callbacks_init_.py:23
10 from langchain_core.callbacks.base import (
11 AsyncCallbackHandler,
12 BaseCallbackHandler,
(...)
20 ToolManagerMixin,
21 )
22 from langchain_core.callbacks.file import FileCallbackHandler
---> 23 from langchain_core.callbacks.manager import (
24 AsyncCallbackManager,
25 AsyncCallbackManagerForChainGroup,
26 AsyncCallbackManagerForChainRun,
27 AsyncCallbackManagerForLLMRun,
28 AsyncCallbackManagerForRetrieverRun,
29 AsyncCallbackManagerForToolRun,
30 AsyncParentRunManager,
31 AsyncRunManager,
32 BaseRunManager,
33 CallbackManager,
34 CallbackManagerForChainGroup,
35 CallbackManagerForChainRun,
36 CallbackManagerForLLMRun,
37 CallbackManagerForRetrieverRun,
38 CallbackManagerForToolRun,
39 ParentRunManager,
40 RunManager,
41 adispatch_custom_event,
42 dispatch_custom_event,
43 )
44 from langchain_core.callbacks.stdout import StdOutCallbackHandler
45 from langchain_core.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

File d:\BTP Work\virtual_environment\Lib\site-packages\langchain_core\callbacks\manager.py:23
12 from typing import (
13 TYPE_CHECKING,
14 Any,
(...)
19 cast,
20 )
21 from uuid import UUID
---> 23 from langsmith.run_helpers import get_tracing_context
24 from tenacity import RetryCallState
26 from langchain_core.callbacks.base import (
27 BaseCallbackHandler,
28 BaseCallbackManager,
(...)
34 ToolManagerMixin,
35 )

File d:\BTP Work\virtual_environment\Lib\site-packages\langsmith\run_helpers.py:45
15 from typing import (
16 TYPE_CHECKING,
17 Any,
(...)
40 runtime_checkable,
41 )
43 from typing_extensions import Annotated, ParamSpec, TypeGuard, get_args, get_origin
---> 45 from langsmith import client as ls_client
46 from langsmith import run_trees, schemas, utils
47 from langsmith._internal import _aiter as aitertools

File d:\BTP Work\virtual_environment\Lib\site-packages\langsmith\client.py:62
60 import requests
61 from requests import adapters as requests_adapters
---> 62 from requests_toolbelt import ( # type: ignore[import-untyped]
63 multipart as rqtb_multipart,
64 )
65 from typing_extensions import TypeGuard, overload
66 from urllib3.poolmanager import PoolKey # type: ignore[attr-defined, import-untyped]

File d:\BTP Work\virtual_environment\Lib\site-packages\requests_toolbelt_init_.py:13
2 """
3 requests-toolbelt
4 =================
(...)
9 :license: Apache v2.0, see LICENSE for more details
10 """
12 from .adapters import SSLAdapter, SourceAddressAdapter
---> 13 from .auth.guess import GuessAuth
14 from .multipart import (
15 MultipartEncoder, MultipartEncoderMonitor, MultipartDecoder,
16 ImproperBodyPartContentException, NonMultipartContentTypeException
17 )
18 from .streaming_iterator import StreamingIterator

File d:\BTP Work\virtual_environment\Lib\site-packages\requests_toolbelt\auth\guess.py:6
3 from requests import auth
4 from requests import cookies
----> 6 from . import _digest_auth_compat as auth_compat, http_proxy_digest
9 class GuessAuth(auth.AuthBase):
10 """Guesses the auth type by the WWW-Authentication header."""

File d:\BTP Work\virtual_environment\Lib\site-packages\requests_toolbelt\auth_digest_auth_compat.py:17
13 def set(self, obj, value):
14 setattr(obj._thread_local, self.prop, value)
---> 17 class _HTTPDigestAuth(requests.auth.HTTPDigestAuth):
18 init = _ThreadingDescriptor('init', True)
19 last_nonce = _ThreadingDescriptor('last_nonce', '')

AttributeError: module 'requests' has no attribute 'auth'

Description

  • I'm just trying to import the langchain_core.prompts library for basic prompting practice.
  • Upon importing, it says the requests module has no attribute auth.

System Info

python -m langchain_core.sys_info yields :
System Information

OS: Windows
OS Version: 10.0.22631
Python Version: 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]

Package Information

langchain_core: 0.3.29
langchain: 0.3.14
langchain_community: 0.3.14
langsmith: 0.2.10
langchain_experimental: 0.3.4
langchain_google_genai: 2.0.8
langchain_ollama: 0.2.2
langchain_openai: 0.3.0
langchain_text_splitters: 0.3.4
langgraph_sdk: 0.1.48

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.11.11
async-timeout: Installed. No version info available.
dataclasses-json: 0.6.7
filetype: 1.2.0
google-generativeai: 0.8.3
httpx: 0.27.2
httpx-sse: 0.4.0
jsonpatch: 1.33
langsmith-pyo3: Installed. No version info available.
numpy: 1.26.4
ollama: 0.4.5
openai: 1.59.3
orjson: 3.10.13
packaging: 24.2
pydantic: 2.10.4
pydantic-settings: 2.7.1
PyYAML: 6.0.2
requests: 2.32.3
requests-toolbelt: 1.0.0
SQLAlchemy: 2.0.36
tenacity: 9.0.0
tiktoken: 0.8.0
typing-extensions: 4.12.2
zstandard: Installed. No version info available.

additionally , pip freeze yielded :
aiohappyeyeballs==2.4.4
aiohttp==3.11.11
aiosignal==1.3.2
annotated-types==0.7.0
anyio==4.8.0
asttokens==3.0.0
attrs==24.3.0
cachetools==5.5.0
certifi==2024.12.14
charset-normalizer==3.4.1
colorama==0.4.6
comm==0.2.2
dataclasses-json==0.6.7
debugpy==1.8.11
decorator==5.1.1
distro==1.9.0
executing==2.1.0
filelock==3.16.1
filetype==1.2.0
frozenlist==1.5.0
fsspec==2024.12.0
google-ai-generativelanguage==0.6.10
google-api-core==2.24.0
google-api-python-client==2.157.0
google-auth==2.37.0
google-auth-httplib2==0.2.0
google-generativeai==0.8.3
googleapis-common-protos==1.66.0
greenlet==3.1.1
grpcio==1.69.0
grpcio-status==1.69.0
h11==0.14.0
httpcore==1.0.7
httplib2==0.22.0
httpx==0.27.2
httpx-sse==0.4.0
huggingface-hub==0.27.1
idna==3.10
ipykernel==6.29.5
ipython==8.31.0
jedi==0.19.2
Jinja2==3.1.5
jiter==0.8.2
joblib==1.4.2
jsonpatch==1.33
jsonpointer==3.0.0
jupyter_client==8.6.3
jupyter_core==5.7.2
langchain==0.3.14
langchain-community==0.3.14
langchain-core==0.3.29
langchain-experimental==0.3.4
langchain-google-genai==2.0.8
langchain-ollama==0.2.2
langchain-openai==0.3.0
langchain-text-splitters==0.3.4
langgraph==0.2.62
langgraph-checkpoint==2.0.9
langgraph-sdk==0.1.48
langsmith==0.2.10
MarkupSafe==3.0.2
marshmallow==3.24.1
matplotlib-inline==0.1.7
mpmath==1.3.0
msgpack==1.1.0
multidict==6.1.0
mypy-extensions==1.0.0
nest-asyncio==1.6.0
networkx==3.4.2
numpy==1.26.4
ollama==0.4.5
openai==1.59.3
orjson==3.10.13
packaging==24.2
pandas==2.2.3
parso==0.8.4
pillow==11.1.0
platformdirs==4.3.6
prompt_toolkit==3.0.48
propcache==0.2.1
proto-plus==1.25.0
protobuf==5.29.2
psutil==6.1.1
pure_eval==0.2.3
pyasn1==0.6.1
pyasn1_modules==0.4.1
pydantic==2.10.4
pydantic-settings==2.7.1
pydantic_core==2.27.2
Pygments==2.19.1
pyparsing==3.2.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.2
pywin32==308
PyYAML==6.0.2
pyzmq==26.2.0
regex==2024.11.6
requests==2.32.3
requests-toolbelt==1.0.0
rsa==4.9
safetensors==0.5.0
scikit-learn==1.6.0
scipy==1.15.0
sentence-transformers==3.3.1
six==1.17.0
sniffio==1.3.1
SQLAlchemy==2.0.36
stack-data==0.6.3
sympy==1.13.1
tenacity==9.0.0
threadpoolctl==3.5.0
tiktoken==0.8.0
tokenizers==0.21.0
torch==2.5.1
tornado==6.4.2
tqdm==4.67.1
traitlets==5.14.3
transformers==4.48.0
typing-inspect==0.9.0
typing_extensions==4.12.2
tzdata==2024.2
uritemplate==4.1.1
urllib3==2.3.0
wcwidth==0.2.13
yarl==1.18.3

@langcarl langcarl bot added the investigate Flagged for investigation. label Jan 14, 2025
@dosubot dosubot bot added 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: core Related to langchain-core labels Jan 14, 2025
@keenborder786
Copy link
Contributor

Please update your langchain_core package. I would recommend to create a new environment and install all the langchain packages in that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: core Related to langchain-core investigate Flagged for investigation.
Projects
None yet
Development

No branches or pull requests

2 participants