Attempting to pip3 install pyportfolioopt
, the build fails with
...ERROR: Failed building wheel for osqp
Failed to build osqp
ERROR: Could not build wheels for osqp, which is required to install pyproject.toml-based projects
...in the traceback, I can see that the problem is
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/bin/cmake", line 5, in <module>
from cmake import cmake
ModuleNotFoundError: No module named 'cmake'
So pip3 install cmake
; pip3 list | grep cmake
: cmake 3.24.0
...try again, but same error.
OSX 12.5 (Monterey) - M1 Chip Python 3.10.6
Edit:
Pleas note that the Python cmake
module is distinct from the cmake
build tool.
So, when I looked in the contents of /Library/Frameworks/Python.framework/Versions/3.10/bin/cmake
there was a from cmake import cmake
line (but no actual file called cmake.py
). So I tried to pip install again:
pip3 install cmake
, which returned the comment: Requirement already satisfied: cmake in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (3.24.0)
...which I don't totally understand as /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10
is a binary file, not a directory, but this puzzlement led me to try: pip3 uninstall cmake
, and then retry installing the original library: pip3 install pyportfolioopt
. Strangely enough, this worked.
So, in short: the way to solve the no module named cmake
bug was to uninstall cmake.... go figure.
Would love any additional insight that anyone can provide though.