1

I have the error "error: command '/usr/bin/g++' failed with exit code 1" when trying to install python package QuTip via Juyter notebook:

enter image description here

and below "error: command '/usr/bin/g++' failed with exit code 1"

enter image description here

= = = =

What fixes can be tried for such error?

= = = =

EDIT: From "g++ --version" I got: Apple clang version 16.0.0 (clang-1600.0.26.4) Target: x86_64-apple-darwin24.1.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin"

= = = =

EDIT 2: Error message from Terminal

qutip/core/data/matmul.cpp:806:10: fatal error: 'algorithm' file not found 806 | #include | ^~~~~~~~~~~ 1 error generated. error: command '/usr/bin/g++' failed with exit code 1 [end of output]

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

= = = =

with verbose:

creating build/temp.macosx-10.9-x86_64-cpython-39/qutip/core/data /usr/bin/g++ -std=c++11 -I./qutip/core/data -I/private/var/folders/yx/m2j_vzc92x90rz6pvbtyr5yh0000gp/T/pip-build-env-54zb7hd_/overlay/lib/python3.9/site-packages/numpy/_core/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c qutip/core/data/ptrace.cpp -o build/temp.macosx-10.9-x86_64-cpython-39/qutip/core/data/ptrace.o -w -O3 -funroll-loops -mmacosx-version-min=10.9 qutip/core/data/ptrace.cpp:810:10: fatal error: 'algorithm' file not found 810 | #include | ^~~~~~~~~~~ 1 error generated. error: command '/usr/bin/g++' failed with exit code 1 error: subprocess-exited-with-error × Building wheel for qutip (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: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /var/folders/yx/m2j_vzc92x90rz6pvbtyr5yh0000gp/T/tmpb5xnoy6m cwd: /private/var/folders/yx/m2j_vzc92x90rz6pvbtyr5yh0000gp/T/pip-install-nhnwe50w/qutip_eac9898a4af34fe48af890fadb95feae Building wheel for qutip (pyproject.toml) ... error ERROR: Failed building wheel for qutip Failed to build qutip ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (qutip)

= = = =

8
  • 3
    Please do not upload images of code/data/errors. Include them as text instead. Commented Dec 16, 2024 at 21:36
  • 2
    The core problem seems to be similar to stackoverflow.com/questions/77250743/… , you can try some of the suggested fixes from there. Commented Dec 16, 2024 at 21:39
  • 2
    Have you installed Xcode through the Apple store? The problem here seems to be that you have the compiler, but it can't find the normal include files. Commented Dec 16, 2024 at 22:15
  • 1
    Minor comment: I don't think it is going to help impacting here in any way, however, using and sharing use of outdated approaches doesn't help you or anyone seeing this, in the long run. Please update your use to use the magic variation of the pip install command when running inside an active Jupyter Notebook session. In this case, it would be specifically, %pip install qutip. The magic pip command variation was added in 2019 to ensure the install occurs in the environment where the kernel is running that backs the active notebook. The exclamation point doesn't do that and can lead to .... Commented Dec 17, 2024 at 15:34
  • 1
    <continued> See more about the modern %pip install command here. The second paragraph here goes into more details about why the exclamation point may lead to issues. Commented Dec 17, 2024 at 15:35

2 Answers 2

1

Jupyter itself doesn't install anything, it comes bundled with Python/Pip which can be used to install dependencies.

Right now your issue is with compiling C code as evident by G++ erroring out. You need to make sure you have all the required dependencies. QuTip requires C++11 or higher. You can check your version with:

g++ --version

If you need to update, it'll depend on what system you have:

brew install gcc or sudo apt-get install g++-11

You should also ensure the correct C compilers and standards are being used:

export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
export CXXFLAGS="-std=c++11"
pip install qutip --no-cache-dir

Finally you can try installing with verbose mode for more details: pip install --verbose qutip

I was able to install this package without issue.

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks, from "g++ --version" I got: Apple clang version 16.0.0 (clang-1600.0.26.4) Target: x86_64-apple-darwin24.1.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin"
I then copy pasted your 4 lines of code and ran but got the same error "1 error generated. error: command '/usr/bin/g++' failed with exit code 1 error: subprocess-exited-with-error" Sorry, I am not good with these things - what else can I try please?
To be clear, those are bash commands. They can't be run in Jupyter (at least I don't think so). Are you running those in terminal or Jupter?
Sorry, I ran these 4 lines in Terminal and got the same error message
You can try running pip with verbose enabled for more details. Is it still failing at #include <algorithm>?
|
1

I had the latest versions of gcc and g++ installed. Instead, updating the packages triggering this issue solved it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.