导入ibmq时出现MissingOptionalLibraryError

0 投票
1 回答
22 浏览
提问于 2025-04-14 16:02

在尝试加载 ibmq 时,使用 from qiskit import IBMQ 这行代码时,我遇到了以下错误,即使我已经运行了 pip install qiskit-ibmq-provider

Unexpected exception formatting exception. Falling back to standard exception
Traceback (most recent call last):
  File "c:\Users\dhruv\AppData\Local\Programs\Python\Python311\Lib\site-packages\qiskit\__init__.py", line 169, in __getattr__
ImportError: cannot import name 'ibmq' from 'qiskit.providers' (c:\Users\dhruv\AppData\Local\Programs\Python\Python311\Lib\site-packages\qiskit\providers\__init__.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\dhruv\AppData\Roaming\Python\Python311\site-packages\IPython\core\interactiveshell.py", line 3442, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "C:\Users\dhruv\AppData\Local\Temp\ipykernel_27528\2346559650.py", line 3, in <module>
    IBMQ.load_account()
    ^^^^^^^^^^^^^^^^^
  File "c:\Users\dhruv\AppData\Local\Programs\Python\Python311\Lib\site-packages\qiskit\__init__.py", line 183, in __getattr__
qiskit.exceptions.MissingOptionalLibraryError: "The 'qiskit-ibmq-provider' library is required to use 'IBMQ provider'. You can install it with 'pip install qiskit-ibmq-provider'."

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\dhruv\AppData\Roaming\Python\Python311\site-packages\IPython\core\interactiveshell.py", line 2057, in showtraceback
    stb = self.InteractiveTB.structured_traceback(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhruv\AppData\Roaming\Python\Python311\site-packages\IPython\core\ultratb.py", line 1118, in structured_traceback
    return FormattedTB.structured_traceback(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dhruv\AppData\Roaming\Python\Python311\site-packages\IPython\core\ultratb.py", line 1012, in structured_traceback
...
           ^^^^^
  File "C:\Users\dhruv\AppData\Roaming\Python\Python311\site-packages\executing\executing.py", line 190, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

有没有人能给点建议?

谢谢

1 个回答

暂无回答

撰写回答