llama-cpp-python: PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package

Traceback (most recent call last):
  File "C:\Users\micro\miniconda3\envs\test\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\micro\miniconda3\envs\test\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\micro\miniconda3\envs\test\lib\site-packages\llama_cpp\server\__main__.py", line 29, in <module>
    from llama_cpp.server.app import create_app, Settings
  File "C:\Users\micro\miniconda3\envs\test\lib\site-packages\llama_cpp\server\app.py", line 15, in <module>
    from pydantic import BaseModel, BaseSettings, Field, create_model_from_typeddict
  File "C:\Users\micro\miniconda3\envs\test\lib\site-packages\pydantic\__init__.py", line 206, in __getattr__
    return _getattr_migration(attr_name)
  File "C:\Users\micro\miniconda3\envs\test\lib\site-packages\pydantic\_migration.py", line 279, in wrapper
    raise PydanticImportError(
pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.0.2/migration/#basesettings-has-moved-to-pydantic-settings for more details.

For further information visit https://errors.pydantic.dev/2.0.2/u/import-error

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 19 (2 by maintainers)

Most upvoted comments

Same, solved it downgrading pydantic pip install pydantic==1.10.11

In the pydantic v2 the BaseSettings has been moved to a different package. First install pydantic-settings by pip install pydantic-settings and replace from pydantic import BaseSettings with from pydantic_settings import BaseSettings

It should work after that.

pip install pydantic==1.10.11 It works! streamlit_pydantic won’t work without this pydantic version downgrade

@dillfrescott was this on a pip install or via git?

FastAPI recently upgraded to pydantic v2 which should be much faster however it does introduce some breaking changes. Can you try upgrading to the new v0.1.69 version I just published?

@Harshad046, pandas_profiling has been deprecated. Use ydata_profiling instead. Uninstall everything and follow the instructions in the link below: https://github.com/ydataai/ydata-profiling

image

@DLesmes it should be resolved with the pydantic-settings dependency in pyproject.toml. If you run try python3 -m pip install pydantic-settings then python3 -c "from pydantic_settings import BaseSettings" does that still cause issues? It may be a mismatch between your pip and python intepreter.

I am running into similar error

it is not resolved, why did you close it @abetlen ❓

despite to do this: pip install pydantic-settings

and run this: from pydantic_settings import BaseSettings

it doesn’t work for many libraries and it’s dependencies 🐍

Glad to see it’s nothing more complex but this really ought to be fixed on the repo