qiskitを入れようとしたら、「Failed to build retworkx」が出たときの原因と解決法

エラー集

出たエラー

 pythonでqiskitというライブラリを入れようとしたところ、下記のエラーが出ました。

ERROR: Command errored out with exit status 1:
command: /Users/daichimizuno/opt/anaconda3/envs/qiskit_environment/bin/python /Users/daichimizuno/opt/anaconda3/envs/qiskit_environment/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/9h/fsmw573j6vv6ltnsvdjxwjrr0000gn/T/tmp2golous5
cwd: /private/var/folders/9h/fsmw573j6vv6ltnsvdjxwjrr0000gn/T/pip-install-misue_j9/retworkx_f431d86c28424aef88a23bb80b77e328
Complete output (25 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.10
creating build/lib.macosx-10.9-x86_64-3.10/retworkx
copying retworkx/init.py -> build/lib.macosx-10.9-x86_64-3.10/retworkx
creating build/lib.macosx-10.9-x86_64-3.10/retworkx/visualization
copying retworkx/visualization/matplotlib.py -> build/lib.macosx-10.9-x86_64-3.10/retworkx/visualization
copying retworkx/visualization/graphviz.py -> build/lib.macosx-10.9-x86_64-3.10/retworkx/visualization
copying retworkx/visualization/init.py -> build/lib.macosx-10.9-x86_64-3.10/retworkx/visualization
running egg_info
writing manifest file ‘retworkx.egg-info/SOURCES.txt’
running build_ext
error: can’t find Rust compiler

If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

To update pip, run:

  pip install --upgrade pip

and then retry package installation.

If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.


ERROR: Failed building wheel for retworkx
Failed to build retworkx
ERROR: Could not build wheels for retworkx, which is required to install pyproject.toml-based projects

解決した方法

 私はAnacondaを使ってpython環境構築していましたが特にこれが関係しているわけではありませんでした。また、エラー中にpipバージョンの記載もありましたが、結果これも関係なかったです。

 原因はpython3.10を利用していたことで、2022/01/10時点ではqiskitはpython3.10は対応していないので、python3.9での環境を作りましょう。Anacondaでの作り方は下記です。「qiskit_environment」の部分は好きな名前を入れて大丈夫です。

conda create -n qiskit_environment python=3.9

以上です。

コメント