You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run the local llama 2-7b version. I've installed llama-cpp-python and all other requirements. When I run the code I constantly get the error which says
Here is my code
`
from langchain.llms import LlamaCpp
from langchain import PromptTemplate, LLMChain
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from pydantic import *
model_prompt = """
Question:What is the largest planet discovered so far?
"""
response = llm(model_prompt)
print(response)
This is the error
PS D:\Python Projects\python> python learn.py
Traceback (most recent call last):
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\pydantic_v1_init_.py", line 15, in
from pydantic.v1 import * # noqa: F403
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\pydantic_init_.py", line 3, in
import pydantic_core
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\pydantic_core_init_.py", line 6, in
from ._pydantic_core import (
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Python Projects\python\learn.py", line 1, in
from langchain.llms import LlamaCpp
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain_init_.py", line 6, in
from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\agents_init_.py", line 31, in
from langchain.agents.agent import (
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\agents\agent.py", line 14, in
from langchain.agents.agent_iterator import AgentExecutorIterator
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\agents\agent_iterator.py", line 21, in
from langchain.callbacks.manager import (
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\callbacks_init_.py", line 10, in
from langchain.callbacks.aim_callback import AimCallbackHandler
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\callbacks\aim_callback.py", line 5, in
from langchain.schema import AgentAction, AgentFinish, LLMResult
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\schema_init_.py", line 3, in
from langchain.schema.cache import BaseCache
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\schema\cache.py", line 6, in
from langchain.schema.output import Generation
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\schema\output.py", line 7, in
from langchain.load.serializable import Serializable
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\load\serializable.py", line 4, in
from langchain.pydantic_v1 import BaseModel, PrivateAttr
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\pydantic_v1_init_.py", line 17, in
from pydantic import * # noqa: F403
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\pydantic_init_.py", line 3, in
import pydantic_core
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\pydantic_core_init_.py", line 6, in
from ._pydantic_core import (
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'
PS D:\Python Projects\python>
`
I tried installing pydantic but to no avail.
Please help
Python version = 3.11.4
pip version =23.2.1
Suggestion:
No response
The text was updated successfully, but these errors were encountered:
dosubotbot
added
Ɑ: models
Related to LLMs or chat model modules
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
labels
Sep 5, 2023
The error you're encountering, "ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'", suggests that the 'pydantic_core._pydantic_core' module is not found in your Python environment. This could be due to a few reasons:
The 'pydantic' package is not installed in your Python environment.
The 'pydantic' package is installed, but the version is not compatible with LangChain.
Here are some steps you can try to resolve this issue:
Install the 'pydantic' package. You can install it using pip:
pip install pydantic
If 'pydantic' is already installed, check its version. LangChain is trying to import from 'pydantic.v1', which suggests that it requires version 1.x of 'pydantic'. You can check the version of 'pydantic' using pip:
pip show pydantic
If the version is not 1.x, you can install the correct version using pip:
pip install pydantic==1.*
If the above steps do not resolve the issue, it could be due to a problem with your Python environment. You can try creating a new virtual environment and installing the required packages there.
In the context shared, LangChain is designed to be compatible with both pydantic v1 and v2. If you're still encountering the issue after following the above steps, it might be due to the specific version of Python you're using. LangChain might not be fully compatible with Python 3.11.4. You could try downgrading to a more stable version of Python, such as Python 3.8 or 3.9, and see if the issue persists.
Please note that these steps are general suggestions based on the provided context. The exact solution may vary depending on your specific setup and environment.
I hope this helps! Let me know if you have any other questions or if the issue persists.
Issue you'd like to raise.
I'm trying to run the local llama 2-7b version. I've installed llama-cpp-python and all other requirements. When I run the code I constantly get the error which says
Here is my code
`
from langchain.llms import LlamaCpp
from langchain import PromptTemplate, LLMChain
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from pydantic import *
MODEL_PATH = "/D:/llama2-7b.bin"
def load_model():
"""Loads Llama model"""
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
Llama_model = LlamaCpp(
model_path=MODEL_PATH,
temperature=0.5,
max_tokens=2000,
top_p=1,
callback_manager=callback_manager,
verbose=True
llm = load_model()
model_prompt = """
Question:What is the largest planet discovered so far?
"""
response = llm(model_prompt)
print(response)
This is the error
PS D:\Python Projects\python> python learn.py
Traceback (most recent call last):
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\pydantic_v1_init_.py", line 15, in
from pydantic.v1 import * # noqa: F403
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\pydantic_init_.py", line 3, in
import pydantic_core
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\pydantic_core_init_.py", line 6, in
from ._pydantic_core import (
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Python Projects\python\learn.py", line 1, in
from langchain.llms import LlamaCpp
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain_init_.py", line 6, in
from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\agents_init_.py", line 31, in
from langchain.agents.agent import (
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\agents\agent.py", line 14, in
from langchain.agents.agent_iterator import AgentExecutorIterator
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\agents\agent_iterator.py", line 21, in
from langchain.callbacks.manager import (
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\callbacks_init_.py", line 10, in
from langchain.callbacks.aim_callback import AimCallbackHandler
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\callbacks\aim_callback.py", line 5, in
from langchain.schema import AgentAction, AgentFinish, LLMResult
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\schema_init_.py", line 3, in
from langchain.schema.cache import BaseCache
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\schema\cache.py", line 6, in
from langchain.schema.output import Generation
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\schema\output.py", line 7, in
from langchain.load.serializable import Serializable
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\load\serializable.py", line 4, in
from langchain.pydantic_v1 import BaseModel, PrivateAttr
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\langchain\pydantic_v1_init_.py", line 17, in
from pydantic import * # noqa: F403
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\pydantic_init_.py", line 3, in
import pydantic_core
File "C:\Users\krish\anaconda3\envs\lang\Lib\site-packages\pydantic_core_init_.py", line 6, in
from ._pydantic_core import (
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'
PS D:\Python Projects\python>
`
I tried installing pydantic but to no avail.
Please help
Python version = 3.11.4
pip version =23.2.1
Suggestion:
No response
The text was updated successfully, but these errors were encountered: