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

Can't run lab 0 locally: ImportError: cannot import name 'ValidationInfo' from 'pydantic' #21

Open
mheiber opened this issue Jun 7, 2024 · 0 comments

Comments

@mheiber
Copy link

mheiber commented Jun 7, 2024

Steps to Repro

clone this repo. I cloned today, and am at: 1041d44
cd ibm-quantum-challenge-2024/content/lab_0
ipython lab-0.ipynb

Tried on an M1 Mac with Python 3.11.5

Actual behavior

The line from qiskit_ibm_runtime import EstimatorV2 as Estimator
fails with ImportError: cannot import name 'ValidationInfo' from 'pydantic'.
This is the same error message as in Qiskit/qiskit-ibm-runtime#1577

Full error message:

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

File ~/anaconda3/lib/python3.11/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 ~/anaconda3/lib/python3.11/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 ~/anaconda3/lib/python3.11/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 ~/anaconda3/lib/python3.11/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 ~/anaconda3/lib/python3.11/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' (/Users/mheiber/anaconda3/lib/python3.11/site-packages/pydantic/__init__.cpython-311-darwin.so)

Expected behavior

Runs without import errors

thanks for your work on the Quantum Challenge

@mheiber mheiber changed the title Can't run first lab locally: ImportError: cannot import name 'ValidationInfo' from 'pydantic' Can't run lab 0 locally: ImportError: cannot import name 'ValidationInfo' from 'pydantic' Jun 7, 2024
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

1 participant