qiskit-aer icon indicating copy to clipboard operation
qiskit-aer copied to clipboard

Don't `decode` a unicode string when using git version

Open garrison opened this issue 11 months ago • 1 comments

Summary

In #907, the git sha1 was added to the version string on development builds. In #2158, encoding="utf-8" was added in _minimal_ext_cmd, which changed the output from a bytestring to a regular string. However, the original code path still expects a bytestring and calls .decode() on it. This fixes it in the way most obvious to me.

Details and comments

I am a bit puzzled that I am the first to notice this. My development builds of Aer otherwise result in the .decode() failing as soon as the package is imported. ~~Even with this change, I am still unable to build and run qiskit-aer in an Ubuntu 24.04 container. The bug I get after this patch is~~

Traceback (most recent call last):
  File "/home/garrison/Qiskit/qiskit-aer/test.py", line 2, in <module>
    from qiskit_aer import AerSimulator
  File "/home/garrison/Qiskit/qiskit-aer/qiskit_aer/__init__.py", line 69, in <module>
    from qiskit_aer.aerprovider import AerProvider
  File "/home/garrison/Qiskit/qiskit-aer/qiskit_aer/aerprovider.py", line 20, in <module>
    from .backends.aer_simulator import AerSimulator
  File "/home/garrison/Qiskit/qiskit-aer/qiskit_aer/backends/__init__.py", line 17, in <module>
    from .aer_simulator import AerSimulator
  File "/home/garrison/Qiskit/qiskit-aer/qiskit_aer/backends/aer_simulator.py", line 24, in <module>
    from .aerbackend import AerBackend, AerError
  File "/home/garrison/Qiskit/qiskit-aer/qiskit_aer/backends/aerbackend.py", line 33, in <module>
    from ..noise.noise_model import NoiseModel, QuantumErrorLocation
  File "/home/garrison/Qiskit/qiskit-aer/qiskit_aer/noise/__init__.py", line 241, in <module>
    from .noise_model import NoiseModel
  File "/home/garrison/Qiskit/qiskit-aer/qiskit_aer/noise/noise_model.py", line 38, in <module>
    from ..backends.backend_utils import BASIS_GATES
  File "/home/garrison/Qiskit/qiskit-aer/qiskit_aer/backends/backend_utils.py", line 30, in <module>
    from .controller_wrappers import aer_initialize_libraries
ModuleNotFoundError: No module named 'qiskit_aer.backends.controller_wrappers'

EDIT: The above error resolved as soon as I changed directories away from the root directory of this repo before importing qiskit_aer.

garrison avatar Nov 22 '24 19:11 garrison