Search code examples
google-colaboratorydrawqiskit

TensorCirucit c.draw() NameError


I want to plot a circuit build with TensorCircuit using the draw method.

I am working on Google Colab and have pip installed qiskit. Yet i get NameError: name 'QuantumCircuit' is not defined. I have also tried from qiskit import QuantumCircuit but still i get the same error.

Executing the code on another JuypterHub works.


Solution

  • pip install qiskit
    pip install pylatexenc
    
    import numpy as np
    from qiskit import *
    

    Once you are done with above code you have to restart your runtime so that installed library come into force into your colab environment.

    For restarting runtime:

    Click on Runtime
    Select Restart runtime 
    Select Run all
    

    This help you to rectify your problem.