Qiskit | ImportError: cannot import name 'Aer' from 'qiskit'', I've tried a lot of attemps to fix this issue and nothing changes

I wanted to run the following part code in jupyter lab:

from qiskit import QuantumCircuit, Aer
import numpy as np
import qiskit.quantum_info as qi
qc = QuantumCircuit(4,4) # Ponemos 4 qubits y 4 bits
# Aplicamos algunas compuertas
qc.x(0)
qc.y(1)
qc.z(2)
.
.
.

And after I runned the code, I encountered the following error:

ImportError                               Traceback (most recent call last)
Cell In[5], line 1
----> 1 from qiskit import QuantumCircuit, Aer
      2 import numpy as np
      3 import qiskit.quantum_info as qi

ImportError: cannot import name 'Aer' from 'qiskit' (C:\Users\hp\anaconda3\Lib\site-packages\qiskit\__init__.py)

In order to fix this problem, I've been:

  1. Reinstalled Qiskit, first putting the command: pip uninstall qiskit and then pip install qiskit in the Anaconda Prompt.
  2. Upgraded Qiskit, with the following command: pip install --upgrade qiskit.
  3. Restarted the Jupyter Lab Kernel.
  4. Checked for conflicting packages, with the following command: pip list. It displayed me a lot of packages I guess, but I coudn´t find the Aer package, Honestly I didn't understand so well this package list.
  5. Searched for documentation abut this Aer package, this gave me to this page: https://qiskit.github.io/qiskit-aer/getting_started.html I tried putting the following command in order to install what I understood the Aer package: pip install qiskit-aer.
  6. Followed the given answer for this similar problem as it was reported in: Qiskit | ImportError: cannot import name 'Aer' from 'qiskit' Doing so, gave me the next error:
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[9], line 1
----> 1 from qiskit_aer import QuantumCircuit, Aer
      2 import numpy as np
      3 import qiskit.quantum_info as qi

ImportError: cannot import name 'QuantumCircuit' from 'qiskit_aer' (C:\Users\hp\anaconda3\Lib\site-packages\qiskit_aer\__init__.py)

So at this stage, I don't know how to attack this problem, somebody help me please.

Upvotes: 1

Views: 1400

Answers (1)

Roy Elkabetz
Roy Elkabetz

Reputation: 151

Just do the following,

from qiskit import QuantumCircuit
from qiskit_aer import Aer

Upvotes: 0

Related Questions