robertmartin8 / PyPortfolioOpt

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

Could not install PyPortfolioOpt even though I have C++ #363

Closed HadrienWind closed 2 years ago

HadrienWind commented 3 years ago

Operating system, environment, python version Windows 10 , anaconda 4.10.3, python 3.8.3

What you tried pip install pyportfolioopt

Error message

C:\Users\hadri>pip install pyportfolioopt
WARNING: Ignoring invalid distribution -umpy (c:\users\hadri\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\users\hadri\anaconda3\lib\site-packages)
Collecting pyportfolioopt
  Using cached PyPortfolioOpt-1.4.2-py3-none-any.whl (60 kB)
Requirement already satisfied: pandas>=0.19 in c:\users\hadri\anaconda3\lib\site-packages (from pyportfolioopt) (1.2.4)
Requirement already satisfied: numpy<2.0,>=1.12 in c:\users\hadri\anaconda3\lib\site-packages (from pyportfolioopt) (1.20.3+vanilla)
Collecting cvxpy<2.0.0,>=1.1.10
  Using cached cvxpy-1.1.14-cp38-cp38-win_amd64.whl (845 kB)
Requirement already satisfied: scipy<2.0,>=1.3 in c:\users\hadri\anaconda3\lib\site-packages (from pyportfolioopt) (1.5.0)
Collecting scs>=1.1.6
  Using cached scs-2.1.4.tar.gz (6.6 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting osqp>=0.4.1
  Using cached osqp-0.6.2.post0-cp38-cp38-win_amd64.whl (162 kB)
Requirement already satisfied: ecos>=2 in c:\users\hadri\anaconda3\lib\site-packages (from cvxpy<2.0.0,>=1.1.10->pyportfolioopt) (2.0.7.post1)
Collecting qdldl
  Using cached qdldl-0.1.5.post0-cp38-cp38-win_amd64.whl (74 kB)
Requirement already satisfied: pytz>=2017.3 in c:\users\hadri\anaconda3\lib\site-packages (from pandas>=0.19->pyportfolioopt) (2020.1)
Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\hadri\anaconda3\lib\site-packages (from pandas>=0.19->pyportfolioopt) (2.8.1)
Requirement already satisfied: six>=1.5 in c:\users\hadri\anaconda3\lib\site-packages (from python-dateutil>=2.7.3->pandas>=0.19->pyportfolioopt) (1.16.0)
Building wheels for collected packages: scs
  Building wheel for scs (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\hadri\anaconda3\python.exe' 'c:\users\hadri\anaconda3\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\hadri\AppData\Local\Temp\tmp47iq0ybn'
       cwd: C:\Users\hadri\AppData\Local\Temp\pip-install-c3pqy44u\scs_26d221611b5c47a397662ae4b29691b1
  Complete output (85 lines):
  Namespace(blas64=False, extraverbose=False, float32=False, gpu=False, gpu_atrans=True, int32=False, scs=False)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.8
  creating build\lib.win-amd64-3.8\scs
  copying src\__init__.py -> build\lib.win-amd64-3.8\scs
  running build_ext
  blas_mkl_info:
    NOT AVAILABLE
  blis_info:
    NOT AVAILABLE
  openblas_info:
      library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas']
      libraries = ['openblas']
      language = f77
      define_macros = [('HAVE_CBLAS', None)]
  blas_opt_info:
      library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas']
      libraries = ['openblas']
      language = f77
      define_macros = [('HAVE_CBLAS', None)]
  lapack_mkl_info:
    NOT AVAILABLE
  openblas_lapack_info:
      library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas']
      libraries = ['openblas']
      language = f77
      define_macros = [('HAVE_CBLAS', None)]
  lapack_opt_info:
      library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas']
      libraries = ['openblas']
      language = f77
      define_macros = [('HAVE_CBLAS', None)]
  Could not locate executable g77
  Could not locate executable f77
  Could not locate executable ifort
  Could not locate executable ifl
  Could not locate executable f90
  Could not locate executable DF
  Could not locate executable efl
  Could not locate executable gfortran
  Could not locate executable f95
  Could not locate executable g95
  Could not locate executable efort
  Could not locate executable efc
  Could not locate executable flang
  don't know how to compile Fortran code on platform 'nt'
  cl : Command line warning D9002 : ignoring unknown option '-O3'
  C:\Users\hadri\AppData\Local\Temp\pip-build-env-qgf2era5\overlay\Lib\site-packages\numpy\distutils\system_info.py:690: UserWarning:
      Optimized (vendor) Blas libraries are not found.
      Falls back to netlib Blas library which has worse performance.
      A better performance should be easily gained by switching
      Blas library.
    self.calc_info()
  C:\Users\hadri\AppData\Local\Temp\pip-build-env-qgf2era5\overlay\Lib\site-packages\numpy\distutils\system_info.py:690: UserWarning:
      Blas (http://www.netlib.org/blas/) libraries not found.
      Directories to search for the libraries can be specified in the
      numpy/distutils/site.cfg file (section [blas]) or by setting
      the BLAS environment variable.
    self.calc_info()
  C:\Users\hadri\AppData\Local\Temp\pip-build-env-qgf2era5\overlay\Lib\site-packages\numpy\distutils\system_info.py:690: UserWarning:
      Blas (http://www.netlib.org/blas/) sources not found.
      Directories to search for the sources can be specified in the
      numpy/distutils/site.cfg file (section [blas_src]) or by setting
      the BLAS_SRC environment variable.
    self.calc_info()
  C:\Users\hadri\AppData\Local\Temp\pip-build-env-qgf2era5\overlay\Lib\site-packages\numpy\distutils\system_info.py:1712: UserWarning:
      Lapack (http://www.netlib.org/lapack/) libraries not found.
      Directories to search for the libraries can be specified in the
      numpy/distutils/site.cfg file (section [lapack]) or by setting
      the LAPACK environment variable.
    if getattr(self, '_calc_info_{}'.format(lapack))():
  C:\Users\hadri\AppData\Local\Temp\pip-build-env-qgf2era5\overlay\Lib\site-packages\numpy\distutils\system_info.py:1712: UserWarning:
      Lapack (http://www.netlib.org/lapack/) sources not found.
      Directories to search for the sources can be specified in the
      numpy/distutils/site.cfg file (section [lapack_src]) or by setting
      the LAPACK_SRC environment variable.
    if getattr(self, '_calc_info_{}'.format(lapack))():
  scsmodule.c
  c:\users\hadri\anaconda3\include\pyconfig.h(206): fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory
  {}
  {}
  error: Command "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYTHON -DCTRLC=1 -DDLONG=1 -DCOPYAMATRIX -Iscs/include -Iscs/linsys -Iscs/linsys/cpu/direct/ -Iscs/linsys/external/amd -Iscs/linsys/external/dqlql -IC:\Users\hadri\AppData\Local\Temp\pip-build-env-qgf2era5\overlay\Lib\site-packages\numpy\core\include -Ic:\users\hadri\anaconda3\include -Ic:\users\hadri\anaconda3\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt /Tcsrc/scsmodule.c /Fobuild\temp.win-amd64-3.8\Release\src/scsmodule.obj -O3" failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for scs
Failed to build scs
ERROR: Could not build wheels for scs which use PEP 517 and cannot be installed directly
WARNING: Ignoring invalid distribution -umpy (c:\users\hadri\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\users\hadri\anaconda3\lib\site-packages)
HadrienWind commented 3 years ago

After Dowloading several times visual studio and pyportfolioOpt, I get the same error message. This is quite strange and I don't quite get it even after reading and installing all the required packages. Could you help me a bit ?

robertmartin8 commented 3 years ago

HI @HadrienWind,

Someone has raised a similar issue on CVXPY's page here and here.

The second link suggests that you need to upgrade C++ from here.

Let me know if that works!

HadrienWind commented 3 years ago

Hey Robert, thanks for the tips, I went deep down with the issues step by step (like a ladder a bit) and the seems came from the Windows 10 SDK that couldn't be dowloaded because of the App Verifier (don't understand why though). So I dowloaded the SDKs separately and, when choosing the packages to install, I unchecked the "App Verifier" bit and all worked fine. Thanks again for the help !!