问题:使用以下代码导入模拟器的包报错:
from qiskit.providers.aer import QasmSimulator
报错信息:
F:\Pycharm\venv\Scripts\python.exe F:/Pycharm/qiskit_test.py
Traceback (most recent call last):
File "F:\Pycharm\qiskit_test.py", line 4, in <module>
from qiskit.providers.aer import QasmSimulator
File "C:\Users\dell\AppData\Local\Programs\Python\Python39\lib\site-packages\qiskit\providers\aer\__init__.py", line 65, in <module>
from .aerprovider import AerProvider
File "C:\Users\dell\AppData\Local\Programs\Python\Python39\lib\site-packages\qiskit\providers\aer\aerprovider.py", line 19, in <module>
from .backends.aer_simulator import AerSimulator
File "C:\Users\dell\AppData\Local\Programs\Python\Python39\lib\site-packages\qiskit\providers\aer\backends\__init__.py", line 17, in <module>
from .aer_simulator import AerSimulator
File "C:\Users\dell\AppData\Local\Programs\Python\Python39\lib\site-packages\qiskit\providers\aer\backends\aer_simulator.py", line 27, in <module>
from .controller_wrappers import aer_controller_execute
ImportError: DLL load failed while importing controller_wrappers: 找不到指定的模块。
最终解决方法:选择使用BasicAer,而不是Aer
from qiskit import BasicAer
# 模拟
simulator = BasicAer.get_backend('qasm_simulator')
?
依稀记得有博主(链接见下)说过Aer出错,可以选择BasicAer代替,我还在想为啥在我自己电脑上跑代码的时候没这么多问题,好家伙我一看我最开始怕出错用的就是BasicAer。
https://blog.csdn.net/qq_36793268/article/details/110346926https://blog.csdn.net/qq_36793268/article/details/110346926
至于为啥用Aer会报错我也没找到答案,我也尝试更改dll文件路径,失败。求大佬指导原因以及解决方法~
|