dspy
dspy copied to clipboard
Getting import issue
Any idea why this below import error?
>>> import dspy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/shared/.miniconda3/envs/py10cuda117/lib/python3.10/site-packages/dspy/__init__.py", line 3, in <module>
from .signatures import *
File "/home/shared/.miniconda3/envs/py10cuda117/lib/python3.10/site-packages/dspy/signatures/__init__.py", line 2, in <module>
from .signature import *
File "/home/shared/.miniconda3/envs/py10cuda117/lib/python3.10/site-packages/dspy/signatures/signature.py", line 220, in <module>
class Signature(BaseModel, metaclass=SignatureMeta):
File "/home/shared/.miniconda3/envs/py10cuda117/lib/python3.10/site-packages/dspy/signatures/signature.py", line 37, in __new__
cls.__doc__ = _default_instructions(cls)
File "/home/shared/.miniconda3/envs/py10cuda117/lib/python3.10/site-packages/dspy/signatures/signature.py", line 19, in _default_instructions
inputs_ = ", ".join([f"`{field}`" for field in cls.input_fields.keys()])
File "/home/shared/.miniconda3/envs/py10cuda117/lib/python3.10/site-packages/dspy/signatures/signature.py", line 94, in input_fields
return cls._get_fields_with_type("input")
File "/home/shared/.miniconda3/envs/py10cuda117/lib/python3.10/site-packages/dspy/signatures/signature.py", line 103, in _get_fields_with_type
for k, v in cls.model_fields.items()
AttributeError: type object '__qualname__' has no attribute 'model_fields'
Python 3.10.13 Installation Command : pip install dspy-ai openai version : 1.3.6
I also started getting this error as of today after updating packages in our project. We also tightened the python requirement to not include 3.11 so we are now on 3.10. Might be a 3.10 issue
Downgraded to 3.1.10 and it worked perfectly
Python 3.10.12 - also getting this error
Is this a pydantic version problem?
Ok let's check. It seems that it works with pip, and it seems that for at least one person poetry doesn't work. Is this what people observe here?
Is this a pydantic version problem?
Upgrading pydantic worked! Thanks!!
How did you guys install?
Fixed I believe. Try now:
pip install -U dspy-ai
We hadn't selected Pydantic >2.0 explicitly
Thanks @okhat , Solved. Closing the issue.
I succeeded.
python=3.10 and use pip install -U dspy-ai
@Zuo-Peng Did you have issues with pip install dspy
?
@tom-doerr There's no problem using pip install dspy
. But need to control the python version.Python version can't be too high.