robertmartin8 / PyPortfolioOpt

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

Could not install on Windows 10 #431

Closed hugheartha closed 10 months ago

hugheartha commented 2 years ago

Operating system, environment, python version Windows, Atom, python3.10

What you tried pip install PyPortfolioOpt

Error message

Collecting PyPortfolioOpt
  Using cached pyportfolioopt-1.5.2-py3-none-any.whl (61 kB)
Requirement already satisfied: pandas>=0.19 in c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages (from PyPortfolioOpt) (1.4.1)
Requirement already satisfied: numpy<2.0,>=1.12 in c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages (from PyPortfolioOpt) (1.22.3)
Collecting cvxpy<2.0.0,>=1.1.10
  Using cached cvxpy-1.2.0-cp310-cp310-win_amd64.whl (832 kB)
Requirement already satisfied: scipy<2.0,>=1.3 in c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages (from PyPortfolioOpt) (1.8.0)
Collecting osqp>=0.4.1
  Using cached osqp-0.6.2.post5-cp310-cp310-win_amd64.whl (278 kB)
Requirement already satisfied: scs>=1.1.6 in c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages (from cvxpy<2.0.0,>=1.1.10->PyPortfolioOpt) (3.2.0)
Collecting ecos>=2
  Using cached ecos-2.0.10-cp310-cp310-win_amd64.whl (68 kB)
Requirement already satisfied: pytz>=2020.1 in c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages (from pandas>=0.19->PyPortfolioOpt) (2022.1)
Requirement already satisfied: python-dateutil>=2.8.1 in c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages (from pandas>=0.19->PyPortfolioOpt) (2.8.2)
Collecting qdldl
  Using cached qdldl-0.1.5.post0.tar.gz (69 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: six>=1.5 in c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages (from python-dateutil>=2.8.1->pandas>=0.19->PyPortfolioOpt) (1.16.0)
Building wheels for collected packages: qdldl
  Building wheel for qdldl (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      running bdist_wheel
      running build
      running build_ext
      -- Selecting Windows SDK version  to target Windows 10.0.19043.
      CMake Error at CMakeLists.txt:4 (project):
        Failed to run MSBuild command:

          MSBuild.exe

        to get the value of VCTargetsPath:

          The system cannot find the file specified

      -- Configuring incomplete, errors occurred!
      See also "C:/Users/Lenovo/AppData/Local/Temp/pip-install-4vni79gw/qdldl_334b9882cceb4736a2c52216f42a0caf/c/build/CMakeFiles/CMakeOutput.log".
      The system cannot find the file specified
      CMake Error: Generator: execution of make failed. Make command was: MSBuild.exe qdldlamd.vcxproj /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0 /v:m &&
      building 'qdldl' extension
      creating build
      creating build\temp.win-amd64-3.10
      creating build\temp.win-amd64-3.10\Release
      creating build\temp.win-amd64-3.10\Release\cpp
      "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Ic -Ic\qdldl\include -IC:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pybind11\include -IC:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pybind11\include -IC:\Users\Lenovo\AppData\Local\Programs\Python\Python310\include -IC:\Users\Lenovo\AppData\Local\Programs\Python\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /EHsc /Tpcpp\qdldl.cpp /Fobuild\temp.win-amd64-3.10\Release\cpp\qdldl.obj -std=c++11
      cl : Command line warning D9002 : ignoring unknown option '-std=c++11'
      qdldl.cpp
      c\qdldl/include/qdldl.h(5): fatal error C1083: Cannot open include file: 'qdldl_types.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for qdldl
  Running setup.py clean for qdldl
Failed to build qdldl
Installing collected packages: qdldl, ecos, osqp, cvxpy, PyPortfolioOpt
  Running setup.py install for qdldl ... error
  error: subprocess-exited-with-error

  × Running setup.py install for qdldl did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      running install
      C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_ext
      -- Selecting Windows SDK version  to target Windows 10.0.19043.
      CMake Error at CMakeLists.txt:4 (project):
        Failed to run MSBuild command:

          MSBuild.exe

        to get the value of VCTargetsPath:

          The system cannot find the file specified

      -- Configuring incomplete, errors occurred!
      See also "C:/Users/Lenovo/AppData/Local/Temp/pip-install-4vni79gw/qdldl_334b9882cceb4736a2c52216f42a0caf/c/build/CMakeFiles/CMakeOutput.log".
      The system cannot find the file specified
      CMake Error: Generator: execution of make failed. Make command was: MSBuild.exe qdldlamd.vcxproj /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0 /v:m &&
      building 'qdldl' extension
      creating build
      creating build\temp.win-amd64-3.10
      creating build\temp.win-amd64-3.10\Release
      creating build\temp.win-amd64-3.10\Release\cpp
      "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Ic -Ic\qdldl\include -IC:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pybind11\include -IC:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\pybind11\include -IC:\Users\Lenovo\AppData\Local\Programs\Python\Python310\include -IC:\Users\Lenovo\AppData\Local\Programs\Python\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /EHsc /Tpcpp\qdldl.cpp /Fobuild\temp.win-amd64-3.10\Release\cpp\qdldl.obj -std=c++11
      cl : Command line warning D9002 : ignoring unknown option '-std=c++11'
      qdldl.cpp
      c\qdldl/include/qdldl.h(5): fatal error C1083: Cannot open include file: 'qdldl_types.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

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

× Encountered error while trying to install package.
╰─> qdldl

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

I have installed Visual Studio 2019 C++ according to the manual, it did not work. Secondly, as seen in other solved issues, I tried to uninstall and install a lower version of Visual Studio 2017 C++ and added the path of MSbuild.exe to the system properties, still could not work.

zulee1711 commented 2 years ago

You can try install the package qdldl manually by download the package from its Pypi. Choose the wheel file that's suitable for your PC & python. Look for:

  1. win_amd64 - window installer
  2. cp310 - python 3.10 Install the downloaded file in terminal with:
    pip install wheel  # install wheel package if haven't already
    pip install C:/some-dir/file_downloaded.whl