stanfordnlp / dspy

DSPy: The framework for programming—not prompting—language models
https://dspy.ai
MIT License
19.27k stars 1.47k forks source link

ImportError: attempted relative import with no known parent package #1639

Closed arthurgreef closed 1 month ago

arthurgreef commented 1 month ago

install dspy-ai 2.5.7

Run a simple predict program.

Exception.

Exception has occurred: ImportError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
attempted relative import with no known parent package
  File ".\.venv\Lib\site-packages\dspy\adapters\chat_adapter.py", line 10, in <module>
    from .base import Adapter
ImportError: attempted relative import with no known parent package

Change line 10 in chat_adapter.py from this:

from .base import Adapter

to this:


from dspy.adapters.base import Adapter
``
okhat commented 1 month ago

Thank you @arthurgreef ! Interesting. Does this happen on old Python? 3.8? It doesn't seem to happen for most people, trying to understand why --- in any case happy to merge this as a PR.

arthurgreef commented 1 month ago

I have python 3.12.7 installed.

arthurgreef commented 1 month ago

This has been fixed in 2.5.13. Thanks.