Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
Operating System
Windows 10 (10.0.19045)
DeepLabCut version
3.0.0rc13
What engine are you using?
pytorch
DeepLabCut mode
single animal
Device type
GeForce RTX 3070
Bug description 🐛
Hello everyone, I hope I'm not posting this in the wrong place.
Anyway, I was setting up deeplabcut on a new machine, with the following commands :
conda create -n DLC python=3.12
conda activate DLC
conda install -c conda-forge pytables==3.8.0
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu126
pip install --pre deeplabcut[gui]
and upon launching deeplabcut, I got the following error:
ImportError: cannot import name 'model_validator' from 'pydantic' (C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\pydantic\__init__.cp312-win_amd64.pyd). Did you mean: 'root_validator'?
I first tried to upgrade/downgrade pydantic which did not fix the issue, however downgrading npe2 from 0.8.0 (recent release!) to 0.7.9 fixed it
pip install npe2==0.7.9
Note sure if the latest npe2 is automatically installed or if I did something that caused the wrong version to be installed.
Steps To Reproduce
No response
Relevant log output
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\deeplabcut\__main__.py", line 33, in <module>
main()
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\deeplabcut\__main__.py", line 25, in main
launch_dlc()
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\deeplabcut\gui\launch_script.py", line 63, in launch_dlc
from deeplabcut.gui.window import MainWindow
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\deeplabcut\gui\window.py", line 29, in <module>
from napari_deeplabcut import misc
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\napari_deeplabcut\__init__.py", line 33, in <module>
from ._writer import write_hdf, write_masks
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\napari_deeplabcut\_writer.py", line 7, in <module>
from napari.layers import Shapes
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\napari\layers\__init__.py", line 9, in <module>
from napari.layers.base import Layer
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\napari\layers\base\__init__.py", line 2, in <module>
from napari.layers.base.base import Layer, no_op
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\napari\layers\base\base.py", line 14, in <module>
from npe2 import plugin_manager as pm
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\npe2\__init__.py", line 11, in <module>
from ._dynamic_plugin import DynamicPlugin
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\npe2\_dynamic_plugin.py", line 16, in <module>
from ._plugin_manager import PluginManager
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\npe2\_plugin_manager.py", line 21, in <module>
from ._command_registry import CommandRegistry
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\npe2\_command_registry.py", line 10, in <module>
from .manifest import utils
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\npe2\manifest\__init__.py", line 1, in <module>
from ._package_metadata import PackageMetadata
File "C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\npe2\manifest\_package_metadata.py", line 4, in <module>
from pydantic import BaseModel, ConfigDict, Field, constr, model_validator
ImportError: cannot import name 'model_validator' from 'pydantic' (C:\Users\plhol\miniconda3\envs\DLC\Lib\site-packages\pydantic\__init__.cp312-win_amd64.pyd). Did you mean: 'root_validator'?Anything else?
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
[-]Incompatibility with latest Npe2 version[/-][+]Incompatibility with latest Npe2 (0.8.0) version[/+][-]Incompatibility with latest Npe2 (0.8.0) version[/-][+]Incompatibility with latest Npe2 (0.8.0) version - solved by downgrading to 0.7.9[/+]deruyter92 commentedon Feb 23, 2026
@piloho, thanks for raising this issue. Normally the dependency resolution by pip should have prevented this mismatch. The issue is that npe2 version 0.8.0 requires pydantic v2 features, but did not accurately specify their dependencies.
I am glad that the issue is resolved for you. Currently we are working on improving the packaging for DeepLabCut with a more modern pyproject.toml (e.g. see #3184). Rather than pinning or restricting versions ourselves based on downstream conflicts, I think the best way forward is to make sure that we use a good dependency resolver, move away from mixed conda + pip installations (e.g. see #3214) and report upstream packaging issues in dependencies for DeepLabCut to the corresponding package maintainers.
In this specific case, the maintainers of npe2 already identified and addressed the problem in their packaging: npe2 0.8.0 has been yanked on PyPI and replaced with a newer 0.8.1. This means that this problem should no longer occur with a fresh install. I am closing this issue.