dspy icon indicating copy to clipboard operation
dspy copied to clipboard

Getting import issue

Open ujjawal-ti opened this issue 11 months ago • 8 comments

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

ujjawal-ti avatar Feb 26 '24 11:02 ujjawal-ti

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

Oyveloper avatar Feb 26 '24 13:02 Oyveloper

Downgraded to 3.1.10 and it worked perfectly

Oyveloper avatar Feb 26 '24 14:02 Oyveloper

Python 3.10.12 - also getting this error

danpechi avatar Feb 26 '24 14:02 danpechi

Is this a pydantic version problem?

okhat avatar Feb 26 '24 15:02 okhat

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?

okhat avatar Feb 26 '24 15:02 okhat

Is this a pydantic version problem?

Upgrading pydantic worked! Thanks!!

danpechi avatar Feb 26 '24 16:02 danpechi

How did you guys install?

okhat avatar Feb 26 '24 16:02 okhat

Fixed I believe. Try now:

pip install -U dspy-ai

We hadn't selected Pydantic >2.0 explicitly

okhat avatar Feb 26 '24 16:02 okhat

Thanks @okhat , Solved. Closing the issue.

ujjawal-ti avatar Feb 27 '24 05:02 ujjawal-ti

I succeeded. python=3.10 and use pip install -U dspy-ai

Zuo-Peng avatar Jun 16 '24 03:06 Zuo-Peng

@Zuo-Peng Did you have issues with pip install dspy?

tom-doerr avatar Jun 16 '24 08:06 tom-doerr

@tom-doerr There's no problem using pip install dspy. But need to control the python version.Python version can't be too high.

Zuo-Peng avatar Jul 08 '24 06:07 Zuo-Peng