Qiskit / qiskit-aer

Aer is a high performance simulator for quantum circuits that includes noise models
https://qiskit.github.io/qiskit-aer/
Apache License 2.0
486 stars 360 forks source link

ImportError: DLL load failed: The specified module could not be found #25

Closed ghost closed 5 years ago

ghost commented 5 years ago

Informations

qiskit 0.7.0 qiskit-aer 0.1.0 qiskit-terra 0.8.0 Windows 10

What is the current behavior?

When running this line: from qiskit.providers.aer import noise I got: from qasm_controller_wrapper import qasm_controller_execute ImportError: DLL load failed: The specified module could not be found.

There are additional error messages: from .aerprovider import AerProvider File "C:\Users\xyz\AppData\Local\Programs\Python\Python36\lib\site-packages\qiskit\providers\aer\aerprovider.py", line 15, in from .backends.qasm_simulator import QasmSimulator File "C:\Users\xyz\AppData\Local\Programs\Python\Python36\lib\site-packages\qiskit\providers\aer\backends__init__.py", line 10, in from .qasm_simulator import QasmSimulator File "C:\Users\xyz\AppData\Local\Programs\Python\Python36\lib\site-packages\qiskit\providers\aer\backends\qasm_simulator.py", line 16, in

Steps to reproduce the problem

Running this line: from qiskit.providers.aer import noise

What is the expected behavior?

Suggested solutions

pecanjk commented 5 years ago

I meet the same problems. This problem comes from the Aer modulor can not be imported you can try from qiskit import Aer and you will get the same ImportError: DLL load failed

atilag commented 5 years ago

Thanks for reporting! I'll look into this

carstenblank commented 5 years ago

I probably had a similar problem. I have posted by solution on stackoverflow:

https://stackoverflow.com/questions/53929599/cannot-import-aer-from-qiskit-0-7/54275759#54275759

To make it short, I found that just copying the legacy simulator's openblas.dll into site-packages solves this for me. Maybe it helps you too?

atilag commented 5 years ago

Yeah, I noticed that. A new version with some bug fixes (this included) is coming very soon.

ghost commented 5 years ago

I probably had a similar problem. I have posted by solution on stackoverflow:

https://stackoverflow.com/questions/53929599/cannot-import-aer-from-qiskit-0-7/54275759#54275759

To make it short, I found that just copying the legacy simulator's openblas.dll into site-packages solves this for me. Maybe it helps you too?

Could you tell the details of doing this: where to get openblas.dll, and where to place it (give folder names)? Thanks!

carstenblank commented 5 years ago

@cubicgate I will clarify, yes! In my setup, I copy from <anaconda_install_dir>\Lib\site-packages\qiskit\providers\legacysimulators\openblas.dll to <anaconda_install_dir>\Lib\site-packages\openblas.dll In general, i.e. using python environments, the openblas.dll must be placed where qiskit-aer has placed its files

I am pretty sure adjusting some path (something equivalent to LD_LIBRARY_PATH) would do the same trick. I wasn't particularly interested in getting much deeper into the subject once I repeatedly was able to fix this issue with the described way. I hope this help!

ghost commented 5 years ago

Hi carstenblank,

Thanks for your detailed tip. It worked for me.

cubicgate

ghost commented 5 years ago

When I run this example at the bottom of this web page: https://github.com/Qiskit/qiskit-aer The following lines: result_noise = execute(circ, simulator, noise_model=noise_model, coupling_map=coupling_map, basis_gates=basis_gates).result()

have this error:

Traceback (most recent call last): File "", line 4, in File "C:\Anaconda3\lib\site-packages\qiskit\tools\compiler.py", line 110, in execute return backend.run(qobj, **kwargs) TypeError: run() got an unexpected keyword argument 'noise_model'

ghost commented 5 years ago

When run these lines: result_noise = execute(circ, simulator, noise_model=noise_model, coupling_map=coupling_map, basis_gates=basis_gates).result()

from this example: https://nbviewer.jupyter.org/github/Qiskit/qiskit-tutorial/blob/master/qiskit/aer/device_noise_simulation.ipynb

Have the same error

carstenblank commented 5 years ago

@cubicgate sorry I think I can't help you there. I have tried the examples, they work for me. However, I notice that you use qiskit-terra 0.8.0. Could it be that is doesn't work with qiskit 0.7.0?

ghost commented 5 years ago

Thanks carstenblank for your kindness to help me. Yes, after I changed to 0.7, it worked for me.

carstenblank commented 5 years ago

Perfect!

carstenblank commented 5 years ago

@atilag thanks a lot, I appreciate the bug fix & looking forward to this!

atilag commented 5 years ago

Latest version of Aer (0.1.1) should have this fixed. I'm closing this issue, reopen it if needed.

thetronjohnson commented 5 years ago

I can't import Aer, I'm getting an import error

sevmardi commented 5 years ago

Still getting this error on python 3.6.2 and using pip. Already upgraded qiskit, but didn't work.

rkochar commented 3 years ago

I too have this problem. I think it should be re-opened (@carstenblank).

Running from qiskit import Aer gives

In [1]: from qiskit import Aer                                                                            
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-5cf2fb0b7167> in <module>
----> 1 from qiskit import Aer

/usr/local/lib/python3.8/dist-packages/qiskit/__init__.py in <module>
     55 # Try to import the Aer provider if installed.
     56 try:
---> 57     from qiskit.providers.aer import Aer
     58 except ImportError:
     59     suppress_warnings = os.environ.get('QISKIT_SUPPRESS_PACKAGING_WARNINGS', '')

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/__init__.py in <module>
     62 
     63 # pylint: disable=wrong-import-position
---> 64 from .aerprovider import AerProvider
     65 from .aerjob import AerJob
     66 from .aererror import AerError

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/aerprovider.py in <module>
     21 from .backends.statevector_simulator import StatevectorSimulator
     22 from .backends.unitary_simulator import UnitarySimulator
---> 23 from .backends.pulse_simulator import PulseSimulator
     24 
     25 

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/backends/__init__.py in <module>
     18 from .statevector_simulator import StatevectorSimulator
     19 from .unitary_simulator import UnitarySimulator
---> 20 from .pulse_simulator import PulseSimulator

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/backends/pulse_simulator.py in <module>
     24 from ..version import __version__
     25 from ..aererror import AerError
---> 26 from ..pulse.controllers.pulse_controller import pulse_controller
     27 from ..pulse.system_models.pulse_system_model import PulseSystemModel
     28 from .aerbackend import AerBackend

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/pulse/__init__.py in <module>
     50 from .qutip_extra_lite.cy import pyxbuilder as pbldr
     51 
---> 52 from .system_models.duffing_model_generators import duffing_system_model
     53 from .system_models.pulse_system_model import PulseSystemModel
     54 

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/pulse/system_models/duffing_model_generators.py in <module>
     19 from collections.abc import Iterable
     20 from qiskit.providers.models.backendconfiguration import UchannelLO
---> 21 from .hamiltonian_model import HamiltonianModel
     22 from .pulse_system_model import PulseSystemModel
     23 

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/pulse/system_models/hamiltonian_model.py in <module>
     20 import numpy.linalg as la
     21 from ...aererror import AerError
---> 22 from .string_model_parser.string_model_parser import HamiltonianParser
     23 
     24 

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/pulse/system_models/string_model_parser/string_model_parser.py in <module>
     21 import numpy as np
     22 from .apply_str_func_to_qobj import apply_func
---> 23 from .qobj_from_string import gen_oper
     24 
     25 

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/pulse/system_models/string_model_parser/qobj_from_string.py in <module>
     16 """Module for creating quantum operators."""
     17 
---> 18 from ...qutip_extra_lite import qobj_generators
     19 
     20 

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/pulse/qutip_extra_lite/qobj_generators.py in <module>
     17 
     18 import numpy as np
---> 19 from . import operators as ops
     20 from . import states as st
     21 from . import tensor as ten

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/pulse/qutip_extra_lite/operators.py in <module>
     54 
     55 import numpy as np
---> 56 from .fastsparse import fast_csr_matrix, fast_identity
     57 from .qobj import Qobj
     58 

/usr/local/lib/python3.8/dist-packages/qiskit/providers/aer/pulse/qutip_extra_lite/fastsparse.py in <module>
    438 # -------------------------------------
    439 # pylint: disable=no-name-in-module, wrong-import-position, import-error
--> 440 from .cy.spmath import (zcsr_transpose, zcsr_adjoint, zcsr_mult)

spmath.pyx in init qiskit.providers.aer.pulse.qutip_extra_lite.cy.spmath()

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

It was suggested on Stackoverflow to try from qiskit.providers.aer import Aer. It gives the same error as above.

SiddhiMali commented 3 years ago

I am having the same problem. The error says 'DLL load failed while importing controller_wrappers: The specified module could not be found.'