robertmartin8 / PyPortfolioOpt

Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
https://pyportfolioopt.readthedocs.io/
MIT License
4.55k stars 959 forks source link

Could not install PyPortfolioOpt on macOS Monterey v. 12.5 #579

Closed PyRickyRa closed 10 months ago

PyRickyRa commented 10 months ago

Hi, i am not able to install PyPortfolioOpt. I have already installed https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/. When I do pip3 install PyPortfolioOpt, then I get:

Defaulting to user installation because normal site-packages is not writeable Collecting PyPortfolioOpt Using cached pyportfolioopt-1.5.5-py3-none-any.whl (61 kB) Collecting cvxpy<2.0.0,>=1.1.19 (from PyPortfolioOpt) Using cached cvxpy-1.4.1-cp39-cp39-macosx_10_9_universal2.whl.metadata (8.8 kB) Requirement already satisfied: numpy<2.0.0,>=1.22.4 in ./Library/Python/3.9/lib/python/site-packages (from PyPortfolioOpt) (1.26.3) Requirement already satisfied: pandas>=0.19 in ./Library/Python/3.9/lib/python/site-packages (from PyPortfolioOpt) (2.1.4) Requirement already satisfied: scipy<2.0,>=1.3 in ./Library/Python/3.9/lib/python/site-packages (from PyPortfolioOpt) (1.11.4) Collecting osqp>=0.6.2 (from cvxpy<2.0.0,>=1.1.19->PyPortfolioOpt) Using cached osqp-0.6.3.tar.gz (228 kB) Installing build dependencies ... error error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> [118 lines of output] Collecting oldest-supported-numpy Using cached oldest_supported_numpy-2023.12.21-py3-none-any.whl.metadata (9.8 kB) Collecting setuptools>=40.8.0 Using cached setuptools-69.0.3-py3-none-any.whl.metadata (6.3 kB) Collecting wheel Using cached wheel-0.42.0-py3-none-any.whl.metadata (2.2 kB) Collecting setuptools_scm>=6.2 Using cached setuptools_scm-8.0.4-py3-none-any.whl.metadata (6.4 kB) Collecting qdldl Using cached qdldl-0.1.7.post0.tar.gz (70 kB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Installing backend dependencies: started Installing backend dependencies: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'done' Collecting numpy==1.21.0 (from oldest-supported-numpy) Using cached numpy-1.21.0-cp39-cp39-macosx_11_0_arm64.whl (12.1 MB) Collecting packaging>=20 (from setuptools_scm>=6.2) Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB) Collecting typing-extensions (from setuptools_scm>=6.2) Using cached typing_extensions-4.9.0-py3-none-any.whl.metadata (3.0 kB) Collecting tomli>=1 (from setuptools_scm>=6.2) Using cached tomli-2.0.1-py3-none-any.whl (12 kB) Collecting scipy>=0.13.2 (from qdldl) Using cached scipy-1.11.4-cp39-cp39-macosx_12_0_arm64.whl.metadata (60 kB) INFO: pip is looking at multiple versions of scipy to determine which version is compatible with other requirements. This could take a while. Using cached scipy-1.11.3-cp39-cp39-macosx_12_0_arm64.whl.metadata (60 kB) Using cached scipy-1.11.2-cp39-cp39-macosx_12_0_arm64.whl.metadata (54 kB) Using cached scipy-1.11.1-cp39-cp39-macosx_12_0_arm64.whl.metadata (54 kB) Using cached scipy-1.10.1-cp39-cp39-macosx_12_0_arm64.whl (28.9 MB) Using cached oldest_supported_numpy-2023.12.21-py3-none-any.whl (4.9 kB) Using cached setuptools-69.0.3-py3-none-any.whl (819 kB) Using cached wheel-0.42.0-py3-none-any.whl (65 kB) Using cached setuptools_scm-8.0.4-py3-none-any.whl (42 kB) Using cached packaging-23.2-py3-none-any.whl (53 kB) Using cached typing_extensions-4.9.0-py3-none-any.whl (32 kB) Building wheels for collected packages: qdldl Building wheel for qdldl (pyproject.toml): started Building wheel for qdldl (pyproject.toml): finished with status 'error' error: subprocess-exited-with-error

    × Building wheel for qdldl (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [65 lines of output]
        running bdist_wheel
        running build
        running build_ext
        Traceback (most recent call last):
          File "<string>", line 81, in build_extensions
          File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 424, in check_output
            return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
          File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 505, in run
            with Popen(*popenargs, **kwargs) as process:
          File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
            self._execute_child(args, executable, preexec_fn, close_fds,
          File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
            raise child_exception_type(errno_num, err_msg, err_filename)
        FileNotFoundError: [Errno 2] No such file or directory: 'cmake'

        During handling of the above exception, another exception occurred:

        Traceback (most recent call last):
          File "/Users//Library/Python/3.9/lib/python/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
            main()
          File "/Users//Library/Python/3.9/lib/python/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
            json_out['return_val'] = hook(**hook_input['kwargs'])
          File "/Users//Library/Python/3.9/lib/python/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
            return _build_backend().build_wheel(wheel_directory, config_settings,
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 404, in build_wheel
            return self._build_with_temp_dir(
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 389, in _build_with_temp_dir
            self.run_setup()
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 311, in run_setup
            exec(code, locals())
          File "<string>", line 113, in <module>
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 103, in setup
            return distutils.core.setup(**attrs)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
            return run_commands(dist)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
            dist.run_commands()
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
            self.run_command(cmd)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 963, in run_command
            super().run_command(command)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
            cmd_obj.run()
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/normal/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 368, in run
            self.run_command("build")
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
            self.distribution.run_command(command)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 963, in run_command
            super().run_command(command)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
            cmd_obj.run()
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 131, in run
            self.run_command(cmd_name)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
            self.distribution.run_command(command)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 963, in run_command
            super().run_command(command)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
            cmd_obj.run()
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 88, in run
            _build_ext.run(self)
          File "/private/var/folders/zk/xjjs_n214yz8vf0gx6p4_b780000gn/T/pip-build-env-34l4ti5y/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
            self.build_extensions()
          File "<string>", line 83, in build_extensions
        RuntimeError: CMake must be installed to build qdldl
        [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for qdldl
  Failed to build qdldl
  ERROR: Could not build wheels for qdldl, which is required to install pyproject.toml-based projects
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

× pip subprocess to install build dependencies 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.

Can you please help me ?

88d52bdba0366127fffca9dfa93895 commented 10 months ago

Hi @PyRickyRa, please see this ticket: https://github.com/robertmartin8/PyPortfolioOpt/issues/426

Or you could try pip install cmake b/c you dont have cmake on your computer.

I'll close this ticket, feel free to re-open it if you need help.

PyRickyRa commented 10 months ago

Still not working

88d52bdba0366127fffca9dfa93895 commented 10 months ago

Ok, please try this to install CMake:

brew install cmake for OS X sudo apt install cmake for Ubuntu

PyRickyRa commented 10 months ago

cmake version 3.28.1 for OS X, but when I do sudo apt install cmake for Ubuntu it tells me: The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit http://www.java.com for information on installing Java.

88d52bdba0366127fffca9dfa93895 commented 10 months ago

Hi @PyRickyRa, please try below commands in order:

pip uninstall cmake

brew uninstall cmake

brew install cmake

pip install pyportfolioopt
88d52bdba0366127fffca9dfa93895 commented 10 months ago

fyi you can see other tickets: https://github.com/robertmartin8/PyPortfolioOpt/issues/561, https://github.com/robertmartin8/PyPortfolioOpt/issues/274