qiskit

Install error in Google Colab


The following is my code:

!pip install qiskit

import datetime
import numpy as np
import pandas as pd
import qiskit
import tensorflow as tf

from qiskit import transpile, assemble, QuantumRegister, QuantumCircuit
from qiskit.providers.ibmq import least_busy
from qiskit.providers.ibmq.job import job_monitor
from qiskit.tools import backend_monitor
from tensorflow.keras.layers import Layer
from dataclasses import dataclass

Everything installed correctly so I'm not sure why I'm getting this error.

Install Error ModuleNotFoundError: 
No module named 'qiskit.providers.ibmq'

I'm just learning Qiskit, so apologies if this is a common question, I just can't seem to find anything that is current. And the install instructions don't seem to indicate any other information than what I've already done here. My only guess is that maybe it's because I'm using Colab?

Does anybody have any idea where the issue can be?


Solution

  • IBM Quantum Provider has its own package now; qiskit-ibm-provider. You have to install it.

    !pip install qiskit
    !pip install qiskit-ibm-provider
    

    And the namespace changed from qiskit.providers.ibmq to qiskit_ibm_provider. So, instead of,

    from qiskit.providers.ibmq import least_busy
    from qiskit.providers.ibmq.job import job_monitor
    

    use:

    from qiskit_ibm_provider import least_busy
    from qiskit_ibm_provider.job import job_monitor