cvxgrp / scs

Splitting Conic Solver
MIT License
554 stars 137 forks source link

Failed building wheel for scs #137

Open lilly-chen opened 4 years ago

lilly-chen commented 4 years ago

Hi, I am trying to install library - PyPortfolioOpt, which requires the scs library. but i am keeping getting the Failed building wheel for scs error and i am not sure how to fix it. here is my error message. any help or feedback on fixing this? Appreciated!

(C:\Users\chenl\Anaconda3) C:\Users\chenl>pip install scs Collecting scs Using cached https://files.pythonhosted.org/packages/1a/72/33be87cce255d4e9dbbfef547e9fd6ec7ee94d0d0910bb2b13badea3fbbe/scs-2.1.2.tar.gz Requirement already satisfied: numpy>=1.7 in c:\users\chenl\anaconda3\lib\site-packages (from scs) (1.15.4) Requirement already satisfied: scipy>=0.13.2 in c:\users\chenl\anaconda3\lib\site-packages (from scs) (1.4.1) Building wheels for collected packages: scs Running setup.py bdist_wheel for scs ... error Complete output from command c:\users\chenl\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\chenl\AppData\Local\Temp\pip-install-bm59zcil\scs\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d C:\Users\chenl\AppData\Local\Temp\pip-wheel-bppycsog --python-tag cp36: Namespace(blas64=False, extraverbose=False, float32=False, gpu=False, int32=False, scs=False) running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\scs copying src__init__.py -> build\lib.win-amd64-3.6\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 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' c:\users\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: UserWarning: Atlas (http://math-atlas.sourceforge.net/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [atlas]) or by setting the ATLAS environment variable. self.calc_info() c:\users\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: 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\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: 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\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: 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. self.calc_info() c:\users\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: 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. self.calc_info() {} error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools


Failed building wheel for scs Running setup.py clean for scs Failed to build scs Installing collected packages: scs Running setup.py install for scs ... error Complete output from command c:\users\chenl\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\chenl\AppData\Local\Temp\pip-install-bm59zcil\scs\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\chenl\AppData\Local\Temp\pip-record-0g1ltf32\install-record.txt --single-version-externally-managed --compile: Namespace(blas64=False, extraverbose=False, float32=False, gpu=False, int32=False, scs=False) running install running build running build_py creating build creating build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\scs copying src__init__.py -> build\lib.win-amd64-3.6\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 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' c:\users\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: UserWarning: Atlas (http://math-atlas.sourceforge.net/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [atlas]) or by setting the ATLAS environment variable. self.calc_info() c:\users\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: 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\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: 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\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: 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. self.calc_info() c:\users\chenl\anaconda3\lib\site-packages\numpy\distutils\system_info.py:625: 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. self.calc_info() {} error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

----------------------------------------

Command "c:\users\chenl\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\chenl\AppData\Local\Temp\pip-install-bm59zcil\scs\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\chenl\AppData\Local\Temp\pip-record-0g1ltf32\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\chenl\AppData\Local\Temp\pip-install-bm59zcil\scs\

bodono commented 4 years ago

The error seems to suggest:

"error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools"

I don't have a windows machine to test on, but the appveyor windows tests are passing so it should work.

1ozturkbe commented 4 years ago

I am having this error too, doing pip install, but unlike above I don't use Anaconda. Definitely have MSVC++ 14.00 as well as higher. For me, fatal error is due to a missing basetsd.h file in python37/include. Might have something to do with Windows SDK installation. If you have any ideas let us know!

1ozturkbe commented 4 years ago

Alright, I fixed issues with basetsd.h, not I am having LINK : fatal error LNK1181: cannot open input file 'openblas_info.lib' What a game of whack-a-mole...

bodono commented 4 years ago

That type of error comes from some mismatch between your numpy install (which is telling SCS where to look for the BLAS libs) and the system. You can install your own lapack / blas library and tell SCS to use those by setting environment variables (just for the install) as used here.

So, if you point the environment variable 'BLAS_LAPACK_LIB_PATHS' to the paths where the libraries are installed, and make 'BLAS_LAPACK_LIBS' the library name (eg, openblas or whatever), then it will install and use those libraries preferentially.

bodono commented 4 years ago

Alternatively try a different conda / numpy version that isn't broken (ie, has correct paths for where the various libs live). This script appears to work at last check: https://github.com/bodono/scs-python/blob/master/.appveyor.yml

1ozturkbe commented 4 years ago

I tried doing both. I built and installed openblas, and pointed the directories, and now I'm getting the following:

       Creating library build\temp.win-amd64-3.7\Release\src\_scs_direct.cp37-win_amd64.lib and object build\temp.win-amd64-3.7\Release\src\_scs_direct.cp37-win_amd64.exp
    aa.obj : error LNK2001: unresolved external symbol dgesv_
    cones.obj : error LNK2001: unresolved external symbol dsyevr_
    build\lib.win-amd64-3.7\_scs_direct.cp37-win_amd64.pyd : fatal error LNK1120: 2 unresolved externals

This is consistent with both a clean install of conda, as well as using openblas built from source. Seems like those lapack functions are not found, although openblas comes with them? This has been absolutely draining my life energy, but I will keep trying. Let me know if you have any ideas.

bodono commented 4 years ago

Two possibilities:

  1. You have installed blas but not lapack, which is also needed.
  2. The symbols in the library you installed are slightly different, and we'll have to do some work to get SCS, which can't know in advance what the library is going to call the various methods, to recognize them. In the main repo we have this, and we might have to do something similar in your case. You will need to inspect the symbols in the blas/lapack library you installed (using something like nm or objdump) to see what the methods are actually called. For example on my mac:
    => nm -gU /usr/lib/liblapack.dylib | grep dsyevr
    00000000001b388d T _dsyevr
    00000000001b388d T _dsyevr_

    which tells me there are symbols for dsyevr with both trailing underscore and not trailing (the leading underscore is not an issue I think). If you installed a 64 bit library you could have something like dseyvr_64, for example.