diff --git a/qiskit/visualization/circuit_visualization.py b/qiskit/visualization/circuit_visualization.py index c25d94797417..65d9c5ffeb0b 100644 --- a/qiskit/visualization/circuit_visualization.py +++ b/qiskit/visualization/circuit_visualization.py @@ -27,6 +27,7 @@ import logging import os +import shutil import subprocess import tempfile from warnings import warn @@ -488,7 +489,7 @@ def _latex_circuit_drawer( image = utils._trim(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-latex-split-filesystem-0c38a1ade2f36e85.yaml b/releasenotes/notes/fix-latex-split-filesystem-0c38a1ade2f36e85.yaml new file mode 100644 index 000000000000..91fd099d3451 --- /dev/null +++ b/releasenotes/notes/fix-latex-split-filesystem-0c38a1ade2f36e85.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixed an ``OSError`` in the LaTeX circuit drawer on systems whose temporary + directories (*e.g* ``/tmp``) are on a different filesystem to the working + directory. See `#8542 `__ + for more detail.