Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'ValidationInfo' from 'pydantic' #2563

Open
jyoung105 opened this issue Apr 17, 2024 · 7 comments
Open

ImportError: cannot import name 'ValidationInfo' from 'pydantic' #2563

jyoung105 opened this issue Apr 17, 2024 · 7 comments

Comments

@jyoung105
Copy link

When I use insightface with pydantic to push on replicate cog, this kind of error starts to appear.

Detail is under.

Validating model schema...
Traceback (most recent call last):
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/cog/command/openapi_schema.py", line 25, in <module>
    raise CogError(app.state.setup_result.logs)
cog.errors.CogError: Error while loading predictor:
Traceback (most recent call last):
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/cog/server/http.py", line 137, in create_app
    predictor = load_predictor_from_ref(predictor_ref)
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/cog/predictor.py", line 187, in load_predictor_from_ref
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "cog/predict.py", line 38, in <module>
    from insightface.app import FaceAnalysis
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/insightface/__init__.py", line 18, in <module>
    from . import app
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/insightface/app/__init__.py", line 2, in <module>
    from .mask_renderer import *
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/insightface/app/mask_renderer.py", line 4, in <module>
    import albumentations as A
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/albumentations/__init__.py", line 3, in <module>
    from .augmentations import *
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/albumentations/augmentations/__init__.py", line 1, in <module>
    from .blur.functional import *
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/albumentations/augmentations/blur/__init__.py", line 1, in <module>
    from .functional import *
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/albumentations/augmentations/blur/functional.py", line 9, in <module>
    from albumentations.augmentations.geometric.functional import scale
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/albumentations/augmentations/geometric/__init__.py", line 2, in <module>
    from .resize import *
  File "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/albumentations/augmentations/geometric/resize.py", line 6, in <module>
    from pydantic import Field, ValidationInfo, field_validator
ImportError: cannot import name 'ValidationInfo' from 'pydantic' (/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/pydantic/__init__.cpython-38-x86_64-linux-gnu.so)
ⅹ Failed to get type signature: exit status 1
@s1ntecs
Copy link

s1ntecs commented May 3, 2024

I have a same problem

@LikeNeko
Copy link

Have you solved it in the end?

@Victoryship
Copy link

pip uninstall pydantic
pip install --upgrade numpy
pip install pyre-extensions==0.0.29
pip install albumentations==1.4.3
pip install pydantic==1.10.13

it works for me

@FilippoStellin
Copy link

pip uninstall pydantic pip install --upgrade numpy pip install pyre-extensions==0.0.29 pip install albumentations==1.4.3 pip install pydantic==1.10.13

it works for me

I found the same error as @jyoung105 and the suggestion of @Victoryship unfortunately did not work for me. My Python version is 3.11.5 (11/09/2023)

@FilippoStellin
Copy link

For the sake of precision, this is the full error message I get when I type from qiskit_ibm_runtime import EstimatorV2 as Estimator inside a Jupyter Notebook:

`ImportError Traceback (most recent call last)
Cell In[33], line 4
2 from qiskit import QuantumCircuit
3 from qiskit.quantum_info import SparsePauliOp
----> 4 from qiskit_ibm_runtime import EstimatorV2 as Estimator
5 from qiskit_aer import AerSimulator
6 import matplotlib.pyplot as plt

File ~\AppData\Roaming\Python\Python311\site-packages\qiskit_ibm_runtime_init_.py:220
217 from .utils.utils import setup_logger
218 from .version import version
--> 220 from .estimator import ( # pylint: disable=reimported
221 EstimatorV2,
222 EstimatorV1,
223 EstimatorV1 as Estimator,
224 )
225 from .sampler import ( # pylint: disable=reimported
226 SamplerV2,
227 SamplerV1,
228 SamplerV1 as Sampler,
229 )
230 from .options import Options, EstimatorOptions, SamplerOptions, OptionsV2

File ~\AppData\Roaming\Python\Python311\site-packages\qiskit_ibm_runtime\estimator.py:30
28 from .runtime_job_v2 import RuntimeJobV2
29 from .ibm_backend import IBMBackend
---> 30 from .options import Options
31 from .options.estimator_options import EstimatorOptions
32 from .base_primitive import BasePrimitiveV1, BasePrimitiveV2

File ~\AppData\Roaming\Python\Python311\site-packages\qiskit_ibm_runtime\options_init_.py:98
1 # This code is part of Qiskit.
2 #
3 # (C) Copyright IBM 2022, 2024
(...)
10 # copyright notice, and modified files need to carry a notice indicating
11 # that they have been altered from the originals.
13 """
14 =====================================================
15 Primitive options (:mod:qiskit_ibm_runtime.options)
(...)
95
96 """
---> 98 from .environment_options import EnvironmentOptions
99 from .execution_options import ExecutionOptions
100 from .execution_options import ExecutionOptionsV2

File ~\AppData\Roaming\Python\Python311\site-packages\qiskit_ibm_runtime\options\environment_options.py:17
13 """Options related to the execution environment."""
15 from typing import Optional, Callable, List, Literal
---> 17 from .utils import primitive_dataclass
19 LogLevelType = Literal[
20 "DEBUG",
21 "INFO",
(...)
24 "CRITICAL",
25 ]
28 @primitive_dataclass
29 class EnvironmentOptions:

File ~\AppData\Roaming\Python\Python311\site-packages\qiskit_ibm_runtime\options\utils.py:23
20 from dataclasses import is_dataclass, asdict
21 from numbers import Real
---> 23 from pydantic import ConfigDict, ValidationInfo, field_validator
24 from pydantic.dataclasses import dataclass
26 from qiskit.providers.backend import Backend

ImportError: cannot import name 'ValidationInfo' from 'pydantic' (C:\ProgramData\anaconda3\Lib\site-packages\pydantic_init_.cp311-win_amd64.pyd)`

@Fl1iz
Copy link

Fl1iz commented Jul 18, 2024

pip uninstall albumentations pydantic
pip install albumentations pydantic==1.10.9

@FilippoStellin
Copy link

Thanks a lot, @Fl1iz . I had finally solved the issue by typing :
! pip install -U jupyter
! pip install --upgrade pydantic
on a jupyterNotebook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants