CPCLAB-UNIPI / SIPPY

Systems Identification Package for PYthon
GNU Lesser General Public License v3.0
269 stars 92 forks source link

Slycot not well installed #30

Closed RBdC closed 3 years ago

RBdC commented 3 years ago

Here we report an important issue received by mail, which may help other users with similar problems ...

"Good afternoon,

I am trying to use SIPPY to identify systems for modal analysis and am having trouble with Slycot. I have all the dependencies for SIPPY installed with pip, but I could not get Slycot installed with pip; for this reason, I installed the pre-compiled version of Slycot from conda-forge using the command found at https://github.com/python-control/Slycot. I believe I have installed Slycot installed properly, because I can import it into a script without errors; however, running EX_SS.py prints “Kalman filter cannot be calculated” 3 times (I’m assuming for the 3 solvers that require Slycot). I have a few questions:

Have you encountered this problem before? Do the other solvers rely on Slycot (will PARSIM-K or ARMAX give inaccurate results because Slycot is not well-installed)? How can I remedy the situation?

I think the issue is that my python interpreter and SIPPY are installed with pip, but Slycot is installed with conda, so SIPPY is not finding the installed version of Slycot. For instance, running the command pytest –pyargs slycot throws errors in pip because slycot is not there, but completes successfully when I run it in Anaconda Prompt. I would greatly appreciate any advice or guidance you have.

Best regards, AS"

RBdC commented 3 years ago

Dear AS,

thanks for the message and the interest in our software package SIPPY.

We have encountered different times problem with the installation of slycot (as evidenced in the user guide https://github.com/CPCLAB-UNIPI/SIPPY/blob/master/user_guide.pdf). Another way useful for installing slycot in mac is running the wheel following the instructions described in https://pypi.org/project/slycot/#description section "From source without conda (Linux, macOS, Windows)".

In addition, about issues induced by slycot affecting the identification methods implemented in SIPPY, as written in the user guide, we know that: For ’N4SID’, ’MOESP’ and ’CVA’ methods, if the message "Kalman filter cannot be calculated" is shown, the problem can be actually due to the fact that the Slycot package is not well installed, since the internal function control.dare is not able to solve the Discrete Algebraic Riccati Equation (DARE). To check if Slycot works properly, use the state space example (Ex_SS.py, attached in Identification_code.zip), where the K should be calculated. Other subspace methods (parsimoniouos PARSIM-S,-K,-P) and also input-output models (as ARMAX) do not use the function DARE, so do not need slycot to be correctly installed, and no problems in the identification results should arise.

SIPPY team

andre-shahinian commented 3 years ago

SIPPY Team,

I tried installing Slycot using the recommended section and got the following error:

Traceback (most recent call last): File "setup.py", line 25, in from skbuild import setup ModuleNotFoundError: No module named 'skbuild'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "setup.py", line 28, in raise ImportError('scikit-build must be installed before running setup.py') ImportError: scikit-build must be installed before running setup.py

However, when I run pip3 install scikit-build, I get the following output:

Requirement already satisfied: scikit-build in c:\users\ashahinian\appdata\local\programs\python\python39\lib\site-packages (0.11.1) Requirement already satisfied: setuptools>=28.0.0 in c:\users\ashahinian\appdata\local\programs\python\python39\lib\site-packages (from scikit-build) (57.4.0) Requirement already satisfied: packaging in c:\users\ashahinian\appdata\local\programs\python\python39\lib\site-packages (from scikit-build) (21.0) Requirement already satisfied: distro in c:\users\ashahinian\appdata\local\programs\python\python39\lib\site-packages (from scikit-build) (1.5.0) Requirement already satisfied: wheel>=0.29.0 in c:\users\ashahinian\appdata\local\programs\python\python39\lib\site-packages (from scikit-build) (0.36.2) Requirement already satisfied: pyparsing>=2.0.2 in c:\users\ashahinian\appdata\local\programs\python\python39\lib\site-packages (from packaging->scikit-build) (2.4.7)

I'm not entirely sure why setup.py cannot find this and run; however, I think I already have Slycot installed. I added import Slycot to Ex_SS.py and ran the code, getting the same output as before I added the line without an error. The Kalman gains still could not be calculated, but I would imagine if slycot were not installed, I could not import it.

Thoughts? -AS

CPCLAB-UNIPI commented 3 years ago

Dear Andre, can you please tell us the version of the slycot and control that you have installed? Maybe there is a problem of inconsistency there.

About the scikit-build installation, have you got other python environments installed in your pc? It seems that when running python setup.py install setup.py is not findining scikit-build in the environment to which the command python is linked.

SIPPY team

andre-shahinian commented 3 years ago

SIPPY Team,

slycot version: 0.4.0 control version: 0.9.0

I had two python environments installed on my pc. One was from pip and the other was from Anaconda. I installed the second one in an attempt to get slycot installed, but have now deleted it to try to install it without conda. This time, the output to the command 'python setup.py install' was:

FC ('-DCMAKE_Fortran_COMPILER=', 'C:/Users/ashahinian/AppData/Local/Programs/Python/Python39/Library/bin/flang.exe')
F2PY ('-DF2PY_EXECUTABLE=', 'C:/Users/ashahinian/AppData/Local/Programs/Python/Python39/Scripts/f2py.exe')
NUMPY_INCLUDE ('-DNumPy_INCLUDE_DIR=', 'C:/Users/ashahinian/AppData/Local/Programs/Python/Python39/Include')
['-DSLYCOT_VERSION:STRING=0.4.0', '-DGIT_REVISION:STRING=ac0944b363a6cfcc0c3d5128cdd484d74173aa3b', '-DISRELEASE:STRING=True', '-DFULL_VERSION=0.4.0.gitac0944b', '-GNMake Makefiles', '-DCMAKE_Fortran_COMPILER=C:/Users/ashahinian/AppData/Local/Programs/Python/Python39/Library/bin/flang.exe', '-DF2PY_EXECUTABLE=C:/Users/ashahinian/AppData/Local/Programs/Python/Python39/Scripts/f2py.exe', '-DNumPy_INCLUDE_DIR=C:/Users/ashahinian/AppData/Local/Programs/Python/Python39/Include', '-DCMAKE_Fortran_SIMULATE_VERSION=5.0.0', '-DCMAKE_Fortran_COMPILER_ID=Flang', '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON']

--------------------------------------------------------------------------------
-- Trying "NMake Makefiles (Visual Studio 15 2017 Win64 v141)" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
Not searching for unused variables given on the command line.
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument  value or use a ... suffix to tell
  CMake that the project does not need compatibility with older versions.

CMake Error at CMakeLists.txt:2 (PROJECT):
  Running

   'nmake' '-?'

  failed with:

   The system cannot find the file specified

-- Configuring incomplete, errors occurred!
See also "C:/Users/ashahinian/Downloads/slycot-0.4.0.0.tar/dist/slycot-0.4.0.0/slycot-0.4.0.0/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "NMake Makefiles (Visual Studio 15 2017 Win64 v141)" generator - failure
--------------------------------------------------------------------------------

********************************************************************************
scikit-build could not get a working generator for your system. Aborting build.

Building windows wheels for Python 3.9 requires Microsoft Visual Studio 2017.
Get it with "Visual Studio 2017":

  https://visualstudio.microsoft.com/vs/

********************************************************************************

Luckily, it was able to find the Fortran compiler (which is a step in the right direction); however, it looks like the issue is with CMake. I don't know why it was able to find the first file and not the second.

Best, AS

CPCLAB-UNIPI commented 3 years ago

Dear Andre, with slycot version: 0.4.0 control version: 0.9.0

EX_SS.py runs smoothly and without errors and it is able to perform identification with all the six methods in the example file.

For the problems with slycot installation, did you succeeded to run it in the same python environment where you installed SIPPY? Please note that if you have more problems when installing slycot refers to this issue or to these repos for more information.

Best regards,

SIPPY team

erik1392 commented 1 year ago

Hello, as I spent almost the whole day debugging the installation of SIPPY in virtual env with pip. I finished with the following error while installing slycot :

  /tmp/pip-build-env-gae35oye/overlay/lib/python3.10/site-packages/numpy/f2py/src/fortranobject.h:7:10: fatal error: Python.h: No such file or directory
      7 | #include <Python.h>
        |          ^~~~~~~~~~

I discovered that besides listed dependencies for slycot it also requires python-dev for the version of python you are using. For me apt install python3.10-dev did the trick.