Nigel1
Nigel1

Reputation: 109

error: command '/usr/bin/g++' failed with exit code 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)

= = = =

Upvotes: 1

Views: 379

Answers (2)

Akaisteph7
Akaisteph7

Reputation: 6416

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

Upvotes: 1

Ali Raza
Ali Raza

Reputation: 323

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.

Upvotes: 1

Related Questions