Skip to content
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.

pip install qiskit does not work on M1-based macs #1201

Closed
nonhermitian opened this issue Mar 28, 2021 · 20 comments · Fixed by #1412
Closed

pip install qiskit does not work on M1-based macs #1201

nonhermitian opened this issue Mar 28, 2021 · 20 comments · Fixed by #1412
Labels
bug Something isn't working

Comments

@nonhermitian
Copy link
Collaborator

Trying to install Qiskit via pip (or pip install -U) fails because there is no compatible aer binary with m1-based macs. Pip just iteratively looks for lower and lower Qiskit versions attempting to find a suitable package.

@nonhermitian nonhermitian added the bug Something isn't working label Mar 28, 2021
@mtreinish
Copy link
Member

This is a bit surprising, while we don't ship arm64 or universal2 macOS binaries yet (we're waiting for numpy and more importantly scipy to do that first before we can add CI jobs for it), both qiskit-terra and qiskit-aer both provide sdist packages which pip should at least try to install from source. What does pip install show with -v set (so pip install -U -v qiskit) it should at least tell us why it's ignoring the aer sdist package on your local system.

@nonhermitian
Copy link
Collaborator Author

I should note that py39 is the only supported version for native m1 support.

@nonhermitian
Copy link
Collaborator Author

Also, scipy and numpy are available from condaforge.

@nonhermitian
Copy link
Collaborator Author

I wonder if this is because the mac builds are 10.9 whereas I think you need 11 for M1 macs.

@denisviklov
Copy link

The same problem here

@SimonKoehl01
Copy link

SimonKoehl01 commented Apr 8, 2021

I am having the same problem atm, installed conda-forge for m1 (which should come with numpy and scipy afaik) but when I try running pip install qiskit it keeps looking for older versions as it says that I has a problem with the cmake installation, with the error being "Failed building wheel for cmake". Also, this is the very firsterror thrown when pip tries get the requirements to build the wheel:

ERROR: Command errored out with exit status 1:
   command: /Users/simonkoehl/miniforge3/bin/python3.9 /Users/simonkoehl/miniforge3/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/kj/r4bf7thj1gg5bp153_b6nf740000gn/T/tmpjimf4uli
       cwd: /private/var/folders/kj/r4bf7thj1gg5bp153_b6nf740000gn/T/pip-install-cod676iy/qiskit-terra_527ecc4e7a454b86b6106da3c6dce55c
  Complete output (24 lines):
  Traceback (most recent call last):
    File "/Users/simonkoehl/miniforge3/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/Users/simonkoehl/miniforge3/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/simonkoehl/miniforge3/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/kj/r4bf7thj1gg5bp153_b6nf740000gn/T/pip-build-env-dpq0fz0p/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 154, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "/private/var/folders/kj/r4bf7thj1gg5bp153_b6nf740000gn/T/pip-build-env-dpq0fz0p/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 135, in _get_build_requires
      self.run_setup()
    File "/private/var/folders/kj/r4bf7thj1gg5bp153_b6nf740000gn/T/pip-build-env-dpq0fz0p/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 258, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/private/var/folders/kj/r4bf7thj1gg5bp153_b6nf740000gn/T/pip-build-env-dpq0fz0p/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 150, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 114, in <module>
      ext_modules=cythonize(EXT_MODULES),
    File "/private/var/folders/kj/r4bf7thj1gg5bp153_b6nf740000gn/T/pip-build-env-dpq0fz0p/overlay/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 965, in cythonize
      module_list, module_metadata = create_extension_list(
    File "/private/var/folders/kj/r4bf7thj1gg5bp153_b6nf740000gn/T/pip-build-env-dpq0fz0p/overlay/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 815, in create_extension_list
      for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
    File "/private/var/folders/kj/r4bf7thj1gg5bp153_b6nf740000gn/T/pip-build-env-dpq0fz0p/overlay/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 114, in nonempty
      raise ValueError(error_msg)
  ValueError: 'qiskit/quantum_info/states/cython/exp_value.pyx' doesn't match any files

@mtreinish
Copy link
Member

mtreinish commented Apr 9, 2021

The error with exp_value.pyx was previously reported and will be fixed in an upcoming bug fix release, probably next week (The sdist for terra 0.17.0 was broken, fixed by: Qiskit/qiskit#6163).

This is the kind of error I would expect though (try and fail to build from sdist), what isn't clear to me is why even outside of that failure, pip on an m1 mac isn't trying to build things from sdist. All the qiskit packages provide an sdist package on pypi so for platforms like the m1 macs (but not exclusively for example ppc64le, s390x, or sparc linux too) pip should be trying to build all the qiskit packages from source. Without the full logs of what is causing pip to reject a qiskit version's sdist (since there won't be any wheel matches) I won't be able to debug this further. (my best guess is that something in the dependency tree is wheel only and doesn't ship m1 compatible wheels, but without the logs I can't confirm or come up with a workaround)

@JRWSP
Copy link

JRWSP commented Apr 15, 2021

FYI, I successful install qiskit on M1 macbook air through Anaconda today. I think we need to run Anaconda (with Rosetta) first and then run pip install qiskit.

@nonhermitian
Copy link
Collaborator Author

So having tried this with 0.25.1 I can confirm that it still does not work when using natively built Python. I am not 100% sure what it going on, but it still tries to downgrade until it fails. Installing Terra, Ignis, and the IBMQ provider all work fine. Aer fails its build, and I assume this is the same issue as before:

-- Conan executing: /Users/paul/mambaforge/envs/qiskit/bin/conan install . -s build_type=Release -s compiler=apple-clang -s compiler.version=12.0 -s compiler.libcxx=libc++ -e=CONAN_CMAKE_PROGRAM=/Users/paul/Downloads/qiskit-aer-0.8.1/.eggs/cmake-3.18.4.post1-py3.9-macosx-10.9-arm64.egg/cmake/data/CMake.app/Contents/bin/cmake -g=cmake --build=missing
ERROR: Invalid setting 'arm64' is not a valid 'settings.arch' value.
Possible values are ['armv4', 'armv4i', 'armv5el', 'armv5hf', 'armv6', 'armv7', 'armv7hf', 'armv7k', 'armv7s', 'armv8', 'armv8.3', 'armv8_32', 'asm.js', 'avr', 'mips', 'mips64', 'ppc32', 'ppc32be', 'ppc64', 'ppc64le', 's390', 's390x', 'sh4le', 'sparc', 'sparcv9', 'wasm', 'x86', 'x86_64']
Read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-invalid-setting"
CMake Error at cmake/conan.cmake:402 (message):
  Conan install failed='1'

@KjellRChristensen
Copy link

HI, I'm sort of having the same issues. I have all qiskit packages installed on my MacBook Pro (M1) and manage to get Aer 0.5.2 installed, but that's where it stops. I also experienced that it rewinded down to 3.1, but you can force pip install using qiskit-aer==0.5.2

Conan is an issues, and the rebuild stops in "AER_DEPENDENCY_PKG::llvm-openmp)" See below!

CMakeList.txt
add_executable(qasm_simulator ${AER_SIMULATOR_SOURCES} ${SIMD_SOURCE_FILE})

conan_utils.cmake
set(AER_LIBRARIES ${AER_LIBRARIES} AER_DEPENDENCY_PKG::llvm-openmp)

@KjellRChristensen
Copy link

I can also confirm that everything is working with Rosetta (VS Code)
qiskit 0.25.2
qiskit-aer 0.8.1
qiskit-aqua 0.9.1
qiskit-ibmq-provider 0.12.3
qiskit-ignis 0.6.0
qiskit-machine-learning 0.1.0
qiskit-optimization 0.1.0
qiskit-terra 0.17.1

@denisviklov
Copy link

It always was there with Aer and error: "ValueError: 'qiskit/quantum_info/states/cython/exp_value.pyx' doesn't match any files"

@denisviklov
Copy link

no updates with Aer?

@denisviklov
Copy link

Any chances that someone fix broken Aer package?

@nickeltingupta
Copy link

I'm having the same issue.

@albspe
Copy link

albspe commented Sep 28, 2021

Any updates on this? I am trying to install on Mac M1 but I see a strange behavior. If it is possible to install qiskit on M1 architecture with conda-forge then it is probably something else on my side. Trying to rule out possible issues. Thx!

@mtreinish
Copy link
Member

You can install everything but qiskit-aer native on an m1 mac currently. Instead of doing pip install qiskit you can do pip install qiskit-terra qiskit-ignis qiskit-ibmq-provider qiskit-aqua (or just the subset you care about). The tracking issue for qiskit-aer is Qiskit/qiskit-aer#1286 (which also has instructions on how to build it from source locally) once that's resolved and included in a qiskit-aer release that includes precompiled binaries for arm64 macOS I'll close this issue.

@lazyoracle
Copy link

I believe this has now been fixed (since Qiskit/qiskit-aer#1362)? I tried installing qiskit with the metapackage (pip install qiskit) on my Apple Silicon Mac today and it worked seamlessly.

@mtreinish
Copy link
Member

It's not fixed for the metapackage yet, Qiskit/qiskit-aer#1362 added support for fixing this, but it hasn't been included in a release yet. We haven't published the precompiled arm64 macOS binary packages to pypi yet. It will be soon though, once Qiskit/qiskit-aer#1458 merges it'll be released then we'll release a new metpackage version (see #1412) which will close this.

@mtreinish mtreinish linked a pull request Feb 9, 2022 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants