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

Qiskit Aer Device Error #441

Open
QuantumResearchbyhimanshu opened this issue Feb 21, 2024 · 1 comment
Open

Qiskit Aer Device Error #441

QuantumResearchbyhimanshu opened this issue Feb 21, 2024 · 1 comment

Comments

@QuantumResearchbyhimanshu

import pennylane as qml
from pennylane import numpy as np

Import the PennyLane Qiskit plugin

dev = qml.device('qiskit.aer', wires=2)

Define a PennyLane QNode

@qml.qnode(dev)
def circuit():
qml.Hadamard(wires=0) # Apply Hadamard gate
qml.CNOT(wires=[0, 1]) # Apply CNOT gate
return qml.probs(wires=[0, 1])

Apply depolarizing noise to the CNOT gate

noise_model = qml.transforms.QubitChannelNoiseModel(qml.channels.DepolarizingChannel, wires=1, probability=0.1)

Apply noise model to the CNOT gate

circuit_with_noise = qml.apply(noise_model, circuit)

Execute the circuit

result = circuit_with_noise()
print(result)

is giving the following error
ImportError: cannot import name 'extensions' from 'qiskit' (/usr/local/lib/python3.10/dist-packages/qiskit/init.py)

I have installed:
!pip install qiskit-aer
!pip install pennylane
!pip install pennylane-qiskit

@lillian542
Copy link
Contributor

Thanks for getting in touch! Qiskit recently released version 1.0, and with it came a lot of changes and removals. Upcoming releases of the plugin will be compatible with the new release of Qiskit, but the 0.34 release predates it, and is not. When you pip install qiskit directly, it installs the most recent version of Qiskit.

Once you have Qiskit 1.0 installed in an environment, trying to downgrade can create issues. The best course of action currently in this case is to create a fresh environment, and then pip install pennylane-qiskit directly (without first installing PennyLane and Qiskit). This will install the relevant version Qiskit for using the device.

If you are using PennyLane via a cloud based service, just restart the kernel and pip install the plugin, no need to worry about environments.

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

2 participants