6

While trying to install cvxpy package using pip install on Mac, I get the following error message:

warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from cvxpy/cvxcore/src/cvxcore.cpp:15:
cvxpy/cvxcore/src/cvxcore.hpp:18:10: fatal error: 'vector' file not found
#include <vector>
^~~~~~~~
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

Mac is running OS Mojave.

Jack Duane
  • 185
  • 3
  • 17
dheena
  • 61
  • 1
  • 4

3 Answers3

11

I solved the issue using the following steps,

First I tried changing the flags to instruct the installation to use libc++,

CFLAGS=-stdlib=libc++ pip install cvxpy

Then it complained about having an invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later).

Then I ran the following command to set the deployment target,

export MACOSX_DEPLOYMENT_TARGET=10.10

Then running the first command(CFLAGS=-stdlib=libc++ pip install cvxpy) again installed cvxpy successfully.

Pubudu Dodangoda
  • 2,742
  • 2
  • 22
  • 38
1

I have been struggling with this all weekend and the most success I have found so far is installing cvxpy in an anaconda environment with these two lines:

conda install -c conda-forge lapack
conda install -c cvxgrp cvxpy
  • Thanks. But I am not using anaconda distribution. I am facing issues in `pip` installation of cvxpy. – dheena Oct 30 '18 at 02:53
  • Updated Mac OS Command Line Tools to version 10.1. After the update `pip install cvxpy` installation worked like a charm. – dheena Nov 01 '18 at 01:14
  • 1
    Using `CFLAGS=-stdlib=libc++` before `pip install cvxpy` like `CFLAGS=-stdlib=libc++ pip install cvxpy` might also work. – dheena Nov 01 '18 at 01:23
  • This worked for me for building fancyimpute on OS X 10.14! – Brian Keegan Dec 24 '18 at 16:56
0

I had a similar error on Mojave. The problem is that the location of the headers installed by XCode command-line tools (which includes clang) have changed. I was able to get it working by adding this to my ~/.bash_profile and opening a new shell:

export CFLAGS="-I/usr/local/include -L/usr/local/lib -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"

This adds flags to CLANG that tell it to run the xcrun command to find the headers. It also adds the homebrew openssl headers to the clang path, which may not be necessary for this case (and assumes you have them installed).

See: https://stackoverflow.com/a/52871908/8344813

Willy Cass
  • 21
  • 5