diff --git a/qiskit/visualization/circuit/circuit_visualization.py b/qiskit/visualization/circuit/circuit_visualization.py index 0627f2617063..ebdffca002a2 100644 --- a/qiskit/visualization/circuit/circuit_visualization.py +++ b/qiskit/visualization/circuit/circuit_visualization.py @@ -28,6 +28,7 @@ import os import subprocess import tempfile +import shutil from warnings import warn from qiskit import user_config @@ -495,7 +496,7 @@ def _latex_circuit_drawer( image = trim_image(image) if filename: if filename.endswith(".pdf"): - os.rename(base + ".pdf", filename) + shutil.move(base + ".pdf", filename) else: try: image.save(filename) diff --git a/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml b/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml new file mode 100644 index 000000000000..fdeec4027e2c --- /dev/null +++ b/releasenotes/notes/fix-regression-in-the-LaTeX-drawer-of-QuantumCircuit-7dd3e84e1dea1abd.yaml @@ -0,0 +1,8 @@ + +fixes: + - | + Fixed a regression in the LaTeX drawer of :meth:`.QuantumCircuit.draw` + when temporary files are placed on a separate filesystem to the working + directory. See + `#10211 `__. +