Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.1k stars 2.34k forks source link

Qiskit doesn't install from source on Windows #12791

Open anedumla opened 2 months ago

anedumla commented 2 months ago

Environment

What is happening?

The following error appears when trying to install qiskit on a clean environment in Windows (pip install qiskit works fine).

I tried both with rustc 1.70.0 and rustc 1.76.0, restarting the laptop, creating a new environtment, etc... but nothing works.

Error message: Running `C:\Users\7G5075848\.rustup\toolchains\1.76.0-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name build_script_build --edition=2018 C:\Users\7G5075848\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ahash-0.7.8\./build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C metadata=5d010ffdd32ed948 -C extra-filename=-5d010ffdd32ed948 --out-dir C:\Users\7G5075848\Box\python_libs\qiskit\target\release\build\ahash-5d010ffdd32ed948 -L dependency=C:\Users\7G5075848\Box\python_libs\qiskit\target\release\deps --extern version_check=C:\Users\7G5075848\Box\python_libs\qiskit\target\release\deps\libversion_check-f28a83bbd8d04604.rlib --cap-lints allow` error[E0463]: can't find crate for `windows_sys` --> C:\Users\7G5075848\.cargo\registry\src\index.crates.io-6f17d22bba15001f\is-terminal-0.4.12\src\lib.rs:48:5 | 48 | use windows_sys::Win32::Foundation::HANDLE; | ^^^^^^^^^^^ can't find crate error[E0463]: can't find crate for `windows_sys` --> C:\Users\7G5075848\.cargo\registry\src\index.crates.io-6f17d22bba15001f\is-terminal-0.4.12\src\lib.rs:115:9 | 115 | use windows_sys::Win32::System::Console::GetConsoleMode; | ^^^^^^^^^^^ can't find crate error[E0463]: can't find crate for `windows_sys` --> C:\Users\7G5075848\.cargo\registry\src\index.crates.io-6f17d22bba15001f\is-terminal-0.4.12\src\lib.rs:140:9 | 140 | use windows_sys::Win32::{ | ^^^^^^^^^^^ can't find crate For more information about this error, try `rustc --explain E0463`. error: could not compile `is-terminal` (lib) due to 3 previous errors Caused by: process didn't exit successfully: `C:\Users\7G5075848\.rustup\toolchains\1.76.0-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name is_terminal --edition=2018 C:\Users\7G5075848\.cargo\registry\src\index.crates.io-6f17d22bba15001f\is-terminal-0.4.12\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 -C metadata=88503cfc54377e33 -C extra-filename=-88503cfc54377e33 --out-dir C:\Users\7G5075848\Box\python_libs\qiskit\target\release\deps -L dependency=C:\Users\7G5075848\Box\python_libs\qiskit\target\release\deps --extern windows_sys=C:\Users\7G5075848\Box\python_libs\qiskit\target\release\deps\libwindows_sys-f5d9125ec2f94eb1.rmeta --cap-lints allow -L native=C:\Users\7G5075848\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows_x86_64_msvc-0.52.6\lib` (exit code: 1) warning: build failed, waiting for other jobs to finish... error: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path crates\pyext\Cargo.toml --release -v --features 'pyo3/extension-module cache_pygates pyo3/abi3-py38' --crate-type cdylib --` failed with code 101 error: subprocess-exited-with-error × Building wheel for qiskit (pyproject.toml) 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. full command: 'C:\Users\7G5075848\Box\python_libs\qiskit\venv\Scripts\python.exe' 'C:\Users\7G5075848\Box\python_libs\qiskit\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py' build_wheel 'C:\Users\7G5075~1\AppData\Local\Temp\tmpgosyforh' cwd: C:\Users\7G5075848\Box\python_libs\qiskit Building wheel for qiskit (pyproject.toml) ... error ERROR: Failed building wheel for qiskit Failed to build qiskit ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (qiskit) ### How can we reproduce the issue? Windows OS, clone qiskit github, then `pip install -v .` ### What should happen? Qiskit should get installed. ### Any suggestions? _No response_
eliarbel commented 2 months ago

Hi @anedumla , thanks for reporting. I got this working on my Windows station: Win11 with Python 3.11 and Rust 1.79. From the error message it seems that you may have a Rust setup or installation issue, or a corrupt cargo registry.
You may want to try to run cargo add windows-sys in some dummy Rust project and build it to add the windows_sys crate. Or try with a newer Rust maybe? I hope these will help.

jakelishman commented 2 months ago

Eli and/or Almudena - are you able to get any success with Rust 1.70 as well? It should be possible to build with Rust 1.70 on Windows since that's our MSRV, so if it only works with 1.79, we ought to work out why and add any workarounds to the building documentation.

anedumla commented 2 months ago
With 1.70 I get the following error, which was the reason I upgraded to 1.76: ``` running build_rust cargo rustc --lib --message-format=json-render-diagnostics --manifest-path crates\pyext\Cargo.toml -v --features cache_pygates pyo3/extension-module --crate-type cdylib -- error: package `triomphe v0.1.13` cannot be built because it requires rustc 1.76 or newer, while the currently active rustc version is 1.70.0 Either upgrade to rustc 1.76 or newer, or use cargo update -p triomphe@0.1.13 --precise ver where `ver` is the latest version of `triomphe` supporting rustc 1.70.0 Traceback (most recent call last): File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools_rust\build.py", line 250, in build_extension cargo_messages = subprocess.check_output( ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\7G5075848\.pyenv\pyenv-win\versions\3.11.9\Lib\subprocess.py", line 466, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\7G5075848\.pyenv\pyenv-win\versions\3.11.9\Lib\subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['cargo', 'rustc', '--lib', '--message-format=json-render-diagnostics', '--manifest-path', 'crates\\pyext\\Cargo.toml', '-v', '--features', 'cache_pygates pyo3/extension-module', '--crate-type', 'cdylib', '--']' returned non-zero exit status 101. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools\command\editable_wheel.py", line 153, in run self._create_wheel_file(bdist_wheel) File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools\command\editable_wheel.py", line 355, in _create_wheel_file files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools\command\editable_wheel.py", line 278, in _run_build_commands self._run_build_subcommands() File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools\command\editable_wheel.py", line 305, in _run_build_subcommands self.run_command(name) File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 316, in run_command self.distribution.run_command(command) File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools\dist.py", line 956, in run_command super().run_command(command) File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 989, in run_command cmd_obj.run() File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools_rust\setuptools_ext.py", line 168, in run build_rust.run() File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools_rust\command.py", line 100, in run self.run_for_extension(ext) File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools_rust\build.py", line 136, in run_for_extension dylib_paths = self.build_extension(ext, self.target) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools_rust\build.py", line 259, in build_extension raise CompileError(format_called_process_error(e, include_stdout=False)) distutils.errors.CompileError: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path crates\pyext\Cargo.toml -v --features 'cache_pygates pyo3/extension-module' --crate-type cdylib --` failed with code 101 C:\Users\7G5075848\AppData\Local\Temp\pip-build-env-ezxexdtt\overlay\Lib\site-packages\setuptools\_distutils\dist.py:989: _DebuggingTips: Problem in editable installation. !! ******************************************************************************** An error happened while installing `qiskit` in editable mode. The following steps are recommended to help debug this problem: - Try to install the project normally, without using the editable mode. Does the error still persist? (If it does, try fixing the problem before attempting the editable mode). - If you are using binary extensions, make sure you have all OS-level dependencies installed (e.g. compilers, toolchains, binary libraries, ...). - Try the latest version of setuptools (maybe the error was already fixed). - If you (or your project dependencies) are using any setuptools extension or customization, make sure they support the editable mode. After following the steps above, if the problem still persists and you think this is related to how setuptools handles editable installations, please submit a reproducible example (see https://stackoverflow.com/help/minimal-reproducible-example) to: https://github.com/pypa/setuptools/issues See https://setuptools.pypa.io/en/latest/userguide/development_mode.html for details. ******************************************************************************** !! cmd_obj.run() error: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path crates\pyext\Cargo.toml -v --features 'cache_pygates pyo3/extension-module' --crate-type cdylib --` failed with code 101 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building editable for qiskit Failed to build qiskit ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (qiskit) ```

Then I tried with 1.79 and adding the windows-sys crate manually (didn't work with a dummy project) but it fails finding a lot of dependecies such as hashbrown, ndarray, num-complex, etc.

jakelishman commented 2 months ago

Hmm, thanks. That error message definitely is indicating a problem with our minimum Rust version on Windows. The other errors about not being able find hashbrown and so on are much much weirder, and are probably something local on your machine - Eli's suggestion above about cache clearing (and making sure you've got an active internet connection, just in case it dropped temporarily...) are all I'd have off the top of my head to try.

eliarbel commented 2 months ago

Eli and/or Almudena - are you able to get any success with Rust 1.70 as well?

I confirm I can install Qiskit with Rust 1.70.