Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.83k stars 2.29k forks source link

WinError 32 during using qiskit.visualization.pass_manager_visualization #12634

Open BStar14 opened 1 week ago

BStar14 commented 1 week ago

Environment

What is happening?

When you try to draw the Graphviz diagram with pass_manager_visualization, You get a PermissionError: [WinError 32] The process cannot access the file because it is being used by another process during running os.remove(tmppath).

How can we reproduce the issue?

from qiskit_ibm_runtime.fake_provider import FakeKyiv
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager

pm = generate_preset_pass_manager(optimization_level=2, backend=FakeKyiv())
pm.draw()

What should happen?

Draw the Graphviz diagram

Any suggestions?

Kind of deep copying the image would work.

with Image.open(tmppath) as image_:
    image = image_.copy()
os.remove(tmppath)
HuangJunye commented 1 week ago

This is similar to https://github.com/Qiskit/qiskit/issues/6005

skwodnjs commented 1 week ago

I can reproduce the issue.