Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error whilst installing ver 0.31.0 #13739

Open
ksk0629 opened this issue Jan 26, 2025 · 5 comments
Open

Error whilst installing ver 0.31.0 #13739

ksk0629 opened this issue Jan 26, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@ksk0629
Copy link

ksk0629 commented Jan 26, 2025

Environment

  • Qiskit version: 0.31.0
  • Python version: 3.8.12
  • Operating system: mac M1 (15.1.1)

What is happening?

I need to install qiskit 0.31.0 for an old project and when installing qiskit 0.31.0 by pip, the following error happens.

Collecting qiskit==0.31
  Using cached qiskit-0.31.0.tar.gz (13 kB)
  Preparing metadata (setup.py) ... done
Collecting qiskit-terra==0.18.3 (from qiskit==0.31)
  Using cached qiskit-terra-0.18.3.tar.gz (5.1 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [53 lines of output]
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                              unsigned long long num_qubits,
                              unsigned long long z_mask,
                              unsigned long long x_mask,
                              complex phase,
                              unsigned int x_max):
              cdef unsigned long long mask_u = ~(2 ** (x_max + 1) - 1)
                                               ^
      ------------------------------------------------------------
      
      qiskit/quantum_info/states/cython/exp_value.pyx:58:41: Invalid operand type for '~' (double)
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                                      unsigned long long num_qubits,
                                      unsigned long long z_mask,
                                      unsigned long long x_mask,
                                      complex phase,
                                      unsigned int x_max):
              cdef unsigned long long mask_u = ~(2 ** (x_max + 1) - 1)
                                               ^
      ------------------------------------------------------------
      
      qiskit/quantum_info/states/cython/exp_value.pyx:120:41: Invalid operand type for '~' (double)
      Compiling qiskit/transpiler/passes/routing/cython/stochastic_swap/utils.pyx because it changed.
      Compiling qiskit/transpiler/passes/routing/cython/stochastic_swap/swap_trial.pyx because it changed.
      Compiling qiskit/quantum_info/states/cython/exp_value.pyx because it changed.
      [1/3] Cythonizing qiskit/quantum_info/states/cython/exp_value.pyx
      Traceback (most recent call last):
        File "/opt/homebrew/Caskroom/miniforge/base/envs/quclassi_ark/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/opt/homebrew/Caskroom/miniforge/base/envs/quclassi_ark/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
        File "/opt/homebrew/Caskroom/miniforge/base/envs/quclassi_ark/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/private/var/folders/ll/szc7m7151ml5z8g80dysyqh00000gn/T/pip-build-env-bh_457o1/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
        File "/private/var/folders/ll/szc7m7151ml5z8g80dysyqh00000gn/T/pip-build-env-bh_457o1/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 303, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/ll/szc7m7151ml5z8g80dysyqh00000gn/T/pip-build-env-bh_457o1/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 521, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/ll/szc7m7151ml5z8g80dysyqh00000gn/T/pip-build-env-bh_457o1/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 319, in run_setup
          exec(code, locals())
        File "<string>", line 141, in <module>
        File "/private/var/folders/ll/szc7m7151ml5z8g80dysyqh00000gn/T/pip-build-env-bh_457o1/overlay/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
          cythonize_one(*args)
        File "/private/var/folders/ll/szc7m7151ml5z8g80dysyqh00000gn/T/pip-build-env-bh_457o1/overlay/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: qiskit/quantum_info/states/cython/exp_value.pyx
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

How can we reproduce the issue?

  1. Create a new virtual environment with python 3.8.12 with conda.
  2. Run pip install qiskit==0.31.0

What should happen?

Qiskit 0.31.0 should be successfully installed.

Any suggestions?

No response

@ksk0629 ksk0629 added the bug Something isn't working label Jan 26, 2025
@jakelishman
Copy link
Member

Qiskit 0.31 is over three years old now, and none of the 0.x series is supported. Back in the 0.31 series, the compiled language used to accelerate Qiskit was Cython (which is relatively hard to build from source, compared to modern Qiskit), and the M1 Mac chip architecture was less than a year old. I think we only published a couple of one-off wheels for M1 Mac back then. Looking at PyPI, I think you might have better luck with Python 3.9.

If you do try to build from source, your best bet will be to check out this repository at the 0.18.3 tag1, and read the "building from source" instructions in the contributing guide from there. At a minimum, you'll need a working C compiler, and you'll probably need to install Cython 0.29.x as a Python package first.

Footnotes

  1. the numbering is weird because qiskit was a metapackage back then, and this repo was called qiskit-terra and had different version numbers.

@jakelishman
Copy link
Member

Looking at your error message in more detail, I'd guess that your modern build is pulling in a too-new version of Cython, and some of its behaviour changed as it went from Cython 0.29 (which was current at the time of Qiskit 0.31 / qiskit-terra 0.18.3) to Cython 3 (a year and a half ago, two years after the version of Qiskit you're trying was released).

@ksk0629
Copy link
Author

ksk0629 commented Jan 26, 2025

@jakelishman Thank you for your answer. I tried the following two and both did not work :(

  • Downgraded Cython to 0.29 and tried to install Qiskit 0.31 with Python 3.8.12.
  • Tried to downgrade Cython to 0.29 with Python 3.9.21.

The first attempt gave me the same error and the second one gave the following error, which I put only the last few messages since it is huge.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cython
  Running setup.py clean for cython
Failed to build cython
ERROR: Failed to build installable wheels for some pyproject.toml based projects (cython)

@ksk0629
Copy link
Author

ksk0629 commented Jan 26, 2025

Oh, also I tried to install Qiskit 0.31 with Python 3.9.21 and got the different error :(

Collecting qiskit==0.31
  Using cached qiskit-0.31.0.tar.gz (13 kB)
  Preparing metadata (setup.py) ... done
Collecting qiskit-terra==0.18.3 (from qiskit==0.31)
  Using cached qiskit_terra-0.18.3-cp39-cp39-macosx_10_9_universal2.whl.metadata (8.3 kB)
Collecting qiskit-aer==0.9.1 (from qiskit==0.31)
  Using cached qiskit-aer-0.9.1.tar.gz (6.5 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [10 lines of output]
      /private/var/folders/ll/szc7m7151ml5z8g80dysyqh00000gn/T/pip-install-1heot8i6/qiskit-aer_5d3d4e0637d54b59835643bb3abcb29e/setup.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
        from pkg_resources import parse_version
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/ll/szc7m7151ml5z8g80dysyqh00000gn/T/pip-install-1heot8i6/qiskit-aer_5d3d4e0637d54b59835643bb3abcb29e/setup.py", line 58, in <module>
          install_needed_req('conans', package_name='conan', min_version='1.31.2')
        File "/private/var/folders/ll/szc7m7151ml5z8g80dysyqh00000gn/T/pip-install-1heot8i6/qiskit-aer_5d3d4e0637d54b59835643bb3abcb29e/setup.py", line 43, in install_needed_req
          mod_ver = parse_version(mod.__version__)
      AttributeError: module 'conans' has no attribute '__version__'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

@jakelishman
Copy link
Member

Ah ok, Aer is a different beast altogether. I don't remember when that started building wheels for M1 Mac, but it may well have been Aer 0.10 or later (you can check on PyPI - go to the release history, the for older releases look for the files and see if they have a macOS "universal" or "arm64" wheel file).

If you've got any other computer you can use for this project, like a Windows or Linux machine, you might have better luck - you're trying to install a package from a time when your CPU architecture was still quite new, so the support is spotty. I think there's a way to use x86_64 Python on ARM Mac too, which might help, but I don't know the detail sorry


For building from source: installing Cython in a virtual environment and then running pip install qiskit-terra==0.18.3 won't work, because pip will create a new isolated virtual environment to build the package in. You're better off cloning this repo at the 0.18.3 tag, installing the setup requirements yourself (in a clean venv), and generally following the repo instructions (from the 0.18.3 tag) to build from source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants