cvxpy: cvxpy fails to install on Apple Silicon under Rosetta2 Homebrew Python

Describe the bug A clear and concise description of what the bug is.

Python 3.9.0_5 installs fine and so do most pypi packages as recommended for Homebrew 2.6.0 using Rosetta2.

Python % arch -x86_64 pip3 install cvxpy
Collecting cvxpy
  Using cached cvxpy-1.1.7.tar.gz (1.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python@3.9/bin/python3.9 /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/tmpwb8n3knm
       cwd: /private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-install-7edffu8y/cvxpy_b036aee14ee549eb9ea539d7d269f653
  Complete output (22 lines):
  Traceback (most recent call last):
    File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-build-env-dcf2qxbq/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 149, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-build-env-dcf2qxbq/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 130, in _get_build_requires
      self.run_setup()
    File "/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-build-env-dcf2qxbq/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 253, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/private/var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/pip-build-env-dcf2qxbq/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 145, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 39, in <module>
      python_target = distutils.version.LooseVersion(
    File "/usr/local/Cellar/python@3.9/3.9.0_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/version.py", line 306, in __init__
      self.parse(vstring)
    File "/usr/local/Cellar/python@3.9/3.9.0_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/version.py", line 314, in parse
      components = [x for x in self.component_re.split(vstring)
  TypeError: expected string or bytes-like object
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python@3.9/bin/python3.9 /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/sj/0mpllhrn5dgbk_sjm6l34jl40000gn/T/tmpwb8n3knm Check the logs for full command output.

To Reproduce A minimal code example that reproduces the bug or unexpected behavior.

See above.

Expected behavior A clear and concise description of what you expected to happen.

Normal pip3 install under Rosetta2

Output If applicable, include program output. If reporting a program crash, please include the entire stack trace.

See above

Version

  • OS: Mac Big Sur 11.0.1
  • CVXPY Version: 1.1.17
  • Apple Mac-mini. 2020.

Additional context Add any other context about the problem here.

Using Rosetta 2 (arch -x86_64), cvxopt, scs and ecos install and run fine. So does Jupyter notebook.

https://brew.sh/2020/12/01/homebrew-2.6.0/

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 31

Most upvoted comments

I think merging this PR in the release branches to backfill wheels is perfectly fine. We’d just be changing infrastructure, not any cvxpy code that a user gets.

I specifically think we can backport wheels for the most recent releases on 1.2.x (i.e., 1.2.1) and 1.1.x (not sure of the precise number).

Thank you @ustunb! It worked for me. I also had to specify ecos==2.0.5 version. See https://github.com/embotech/ecos-python/issues/33

Thank you!

I installed cmake using homebrew and it worked!

In case anyone else runs into this issue, the command that I ran was:

pip install -U --no-use-pep517 --no-cache-dir cvxpy

This installed cvxpy-1.1.17

I had also installed openblas via brew, and also had scipy and numpy installed.

You should no longer need to use the --no-use-pep517 flag if you’re building CVXPY 1.1.19 (or newer in the 1.1.x release series) or anything in the 1.2.x release series. The web documentation for those releases will mention the need for cmake and a suitable version of ECOS.

I’ll leave this issue open so it’s easy for people to find until installation becomes more seamless.

Oh, that seems bad.

I will take a look this weekend or early next week, since I’m finishing up a paper.

Hi all. Im still unable to pip install cvxpy on my mac M1. I installed cmake with homebrew, and im using ECOS 2.0.5. Im using python 3.8.10 and here are my current packages:

ecos 2.0.5 numpy 1.22.4 osqp 0.6.2.post5 pip 22.1.2 pybind11 2.9.2 qdldl 0.1.5.post2 scipy 1.8.1 setuptools 56.0.0

The issue appears to be that despite having numpy 1.22.4, it trys to get numpy-1.16.6 and then that fails.

Any thoughts?