PrefectHQ / marvin

✨ Build AI interfaces that spark joy
https://askmarvin.ai
Apache License 2.0
5.17k stars 327 forks source link

Failing to import marvin with "ImportError: cannot import name 'BaseSettings'" after installing using pip install in Github Codespaces #605

Open dirkjbreeuwer opened 11 months ago

dirkjbreeuwer commented 11 months ago

First check

Bug summary

import marvin Failing with import error after clean installation using pip install marvin.

This error does not happen when I install using the developer install instructions (git clone, etc).

Reproduction

1. Create a new Github Codespace
2.  install marvin
3. ```pip install pydantic-settings```
4. Create a new jupyter notebook: experiments.ipynb
5. ```import marvin```
6. ImportError: cannot import name 'BaseSettings' from 'marvin._compat'

Error

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/workspaces/marvin/experiments.ipynb Cell 1 line 1
----> 1 import marvin

File /workspaces/marvin/venv/lib/python3.10/site-packages/marvin/__init__.py:1
----> 1 from .settings import settings
      3 from .components import (
      4     ai_classifier,
      5     ai_fn,
   (...)
     10     AIModelFactory,
     11 )
     13 try:

File /workspaces/marvin/venv/lib/python3.10/site-packages/marvin/settings.py:8
      4 from typing import Any, Literal, Optional, Union
      6 from pydantic import Field, SecretStr
----> 8 from ._compat import BaseSettings, SettingsConfigDict, field_validator
     10 ENV_PATH = Path(os.getenv("MARVIN_ENV_FILE", "~/.marvin/.env")).expanduser()
     13 class MarvinBaseSettings(BaseSettings):

ImportError: cannot import name 'BaseSettings' from 'marvin._compat' (/workspaces/marvin/venv/lib/python3.10/site-packages/marvin/_compat.py

Versions

Version:                1.5.1
Python version:         3.10.8
OS/Arch:                linux/x86_64

Additional context

No response

aaazzam commented 11 months ago

hey @dirkjbreeuwer, good catch.

We have an import error telling people to install pydantic-settings, but because of some boneheadedness that message isn't showing up and it just looks like a sloppy missing dependency.

have a PR addressing this, pending tests. Thanks for catching this!

dsaks9 commented 11 months ago

is there currently a workaround?

aaazzam commented 11 months ago

Yep! Just pip install pydantic-basesetting

On Wed, Oct 4, 2023 at 10:26 AM Delon @.***> wrote:

is there currently a workaround?

— Reply to this email directly, view it on GitHub https://github.com/PrefectHQ/marvin/issues/605#issuecomment-1746980813, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH4DG2O2PEQUG2X3CPSMOE3X5VW2HAVCNFSM6AAAAAA5O6OBKWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBWHE4DAOBRGM . You are receiving this because you commented.Message ID: @.***>

dsaks9 commented 11 months ago

thanks, if using Pydantic V2 looks like you want to install pydantinc-settings instead of pydantic-basesetting

llermaly commented 11 months ago

thanks, if using Pydantic V2 looks like you want to install pydantinc-settings instead of pydantic-basesetting

typo. it is pydantic-settings took me a while catch it