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 957 forks source link

Not comptible with Python 3.12 #564

Closed BeachGuy007 closed 11 months ago

BeachGuy007 commented 1 year ago

Installed Python 3.12. Received error pypfopt not installed. Did a pip install but that failed on several sub routines

Expected behavior Module runs as expected with no errors

Code sample import pandas as pd from pypfopt.discrete_allocation import DiscreteAllocation, get_latest_prices

Operating system, python version, PyPortfolioOpt version e.g WIN11 Pro, Build 22621.2428, python 3.12, PyPortfolioOpt 1.5.5

Additional context Add any other context about the problem here.

pip.exe install PyPortfolioOpt 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.tar.gz (1.6 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Requirement already satisfied: numpy<2.0.0,>=1.22.4 in c:\users\bill\appdata\local\programs\python\python312\lib\site-packages (from PyPortfolioOpt) (1.26.1) Requirement already satisfied: pandas>=0.19 in c:\users\bill\appdata\local\programs\python\python312\lib\site-packages (from PyPortfolioOpt) (2.1.1) Requirement already satisfied: scipy<2.0,>=1.3 in c:\users\bill\appdata\local\programs\python\python312\lib\site-packages (from PyPortfolioOpt) (1.11.3) 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 ╰─> [133 lines of output] Collecting oldest-supported-numpy Obtaining dependency information for oldest-supported-numpy from https://files.pythonhosted.org/packages/94/9a/756fef9346e5ca2289cb70d73990b4c9f25446a885c1186cfb93a85e7da0/oldest_supported_numpy-2023.8.3-py3-none-any.whl.metadata Using cached oldest_supported_numpy-2023.8.3-py3-none-any.whl.metadata (9.5 kB) Collecting setuptools>=40.8.0 Obtaining dependency information for setuptools>=40.8.0 from https://files.pythonhosted.org/packages/bb/26/7945080113158354380a12ce26873dd6c1ebd88d47f5bc24e2c5bb38c16a/setuptools-68.2.2-py3-none-any.whl.metadata Using cached setuptools-68.2.2-py3-none-any.whl.metadata (6.3 kB) Collecting wheel Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/b8/8b/31273bf66016be6ad22bb7345c37ff350276cfd46e389a0c2ac5da9d9073/wheel-0.41.2-py3-none-any.whl.metadata Using cached wheel-0.41.2-py3-none-any.whl.metadata (2.2 kB) Collecting setuptools_scm>=6.2 Obtaining dependency information for setuptools_scm>=6.2 from https://files.pythonhosted.org/packages/0e/a3/b9a8b0adfe672bf0df5901707aa929d30a97ee390ba651910186776746d2/setuptools_scm-8.0.4-py3-none-any.whl.metadata 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 (from oldest-supported-numpy) Obtaining dependency information for numpy from https://files.pythonhosted.org/packages/32/95/908d0caa051beae4f7c77652dbbeb781e7b717f3040c5c5fcaed4d3ed08f/numpy-1.26.1-cp312-cp312-win_amd64.whl.metadata Using cached numpy-1.26.1-cp312-cp312-win_amd64.whl.metadata (61 kB) Collecting packaging>=20 (from setuptools_scm>=6.2) Obtaining dependency information for packaging>=20 from https://files.pythonhosted.org/packages/ec/1a/610693ac4ee14fcdf2d9bf3c493370e4f2ef7ae2e19217d7a237ff42367d/packaging-23.2-py3-none-any.whl.metadata Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB) Collecting typing-extensions (from setuptools_scm>=6.2) Obtaining dependency information for typing-extensions from https://files.pythonhosted.org/packages/24/21/7d397a4b7934ff4028987914ac1044d3b7d52712f30e2ac7a2ae5bc86dd0/typing_extensions-4.8.0-py3-none-any.whl.metadata Using cached typing_extensions-4.8.0-py3-none-any.whl.metadata (3.0 kB) Collecting scipy>=0.13.2 (from qdldl) Obtaining dependency information for scipy>=0.13.2 from https://files.pythonhosted.org/packages/f4/ce/be0b376ba6069f3f8ba240aa532a374733447453c93582d4c474effdde21/scipy-1.11.3-cp312-cp312-win_amd64.whl.metadata Using cached scipy-1.11.3-cp312-cp312-win_amd64.whl.metadata (60 kB) Using cached oldest_supported_numpy-2023.8.3-py3-none-any.whl (4.8 kB) Using cached setuptools-68.2.2-py3-none-any.whl (807 kB) Using cached wheel-0.41.2-py3-none-any.whl (64 kB) Using cached setuptools_scm-8.0.4-py3-none-any.whl (42 kB) Using cached numpy-1.26.1-cp312-cp312-win_amd64.whl (15.5 MB) Using cached packaging-23.2-py3-none-any.whl (53 kB) Using cached scipy-1.11.3-cp312-cp312-win_amd64.whl (43.7 MB) Using cached typing_extensions-4.8.0-py3-none-any.whl (31 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

    [73 lines of output]
    running bdist_wheel
    running build
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 81, in build_extensions
      File "C:\Users\Bill\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 466, in check_output
        return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Bill\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 548, in run
        with Popen(*popenargs, **kwargs) as process:
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Bill\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "C:\Users\Bill\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child
        hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    FileNotFoundError: [WinError 2] The system cannot find the file specified

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\Users\Bill\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
        main()
      File "C:\Users\Bill\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Bill\AppData\Local\Programs\Python\Python312\Lib\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 "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\build_meta.py", line 434, in build_wheel
        return self._build_with_temp_dir(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\build_meta.py", line 419, in _build_with_temp_dir
        self.run_setup()
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\build_meta.py", line 341, in run_setup
        exec(code, locals())
      File "<string>", line 113, in <module>
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\__init__.py", line 103, in setup
        return distutils.core.setup(**attrs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
        return run_commands(dist)
               ^^^^^^^^^^^^^^^^^^
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
        dist.run_commands()
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
        self.run_command(cmd)
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\dist.py", line 989, in run_command
        super().run_command(command)
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
        cmd_obj.run()
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\normal\Lib\site-packages\wheel\bdist_wheel.py", line 364, in run
        self.run_command("build")
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\dist.py", line 989, in run_command
        super().run_command(command)
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
        cmd_obj.run()
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run
        self.run_command(cmd_name)
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\dist.py", line 989, in run_command
        super().run_command(command)
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
        cmd_obj.run()
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\site-packages\setuptools\command\build_ext.py", line 88, in run
        _build_ext.run(self)
      File "C:\Users\Bill\AppData\Local\Temp\pip-build-env-3an8bra3\overlay\Lib\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

  [notice] A new release of pip is available: 23.2.1 -> 23.3
  [notice] To update, run: python.exe -m pip install --upgrade pip
  [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.

88d52bdba0366127fffca9dfa93895 commented 11 months ago

hi @BeachGuy007, your log said "RuntimeError: CMake must be installed to build qdldl". Please check the CMake, it's not an error with pypfopt.

see also https://github.com/robertmartin8/PyPortfolioOpt/issues/525