qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

WinError 32 during using qiskit.visualization.pass_manager_visualization

Open BStar14 opened this issue 8 months ago • 2 comments

Environment

  • Qiskit version: 1.1.1
  • Python version: 3.12.3
  • Operating system: Windows 11

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)

BStar14 avatar Jun 21 '24 13:06 BStar14