pythonpython-3.xpipquantum-computingqiskit

How can I visualize image using qiskit in vscode?


I'm now trying to run qiskit visualization functions(e.g. .draw() methods) in vscode.

I use latest version of Python, 3.11.1, and followed Getting Started Qiskit in here. Also I installed qiskit extension in vscode.

However, when I run a qiskit code, the visualization functions don't work, even though code is compiled successfully.

I checked visualizing modules(mathplotlib, etc.) were installed.

I tried to re-install Python and vscode, including downgrading Python to 3.8. And it didn't work.

Additionally, qiskit-chemistry and qiskit-aqua installation warnings are pop-upped, but installation doesn't work.

I really don't know it is related on this problem, but I think maybe it's not since qiskit-aqua is deprecated.

The following screenshot is result of the qiskit test code.

result of running

draw() and plot_histogram() doesn't work as you can see.

How can I fix this problem?


Solution

  • These functions are meant to be used in Python Notebooks - they won't show up in normal .py files. Try using VSCode's Jupyter Notebook (.ipynb files) feature instead.