Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Slycot on Windows 11 failing #223

Closed
TomLXXVI opened this issue Nov 5, 2023 · 4 comments
Closed

Install Slycot on Windows 11 failing #223

TomLXXVI opened this issue Nov 5, 2023 · 4 comments
Labels
build system Issues with compiling, linking and installing Slycot

Comments

@TomLXXVI
Copy link

TomLXXVI commented Nov 5, 2023

I use Pycharm on a Windows 11 computer. For a new project I wanted to use the Python Control Systems library. I created a virtual environment using conda. With the virtual environment being active, I installed the package with the instruction conda install -c conda-forge control slycot on the command line. The version of control is 0.9.4, and the version of slycot is 0.5.4.

Somewhere in my code I call ct_ss, _ = ct.canonical_form(self._ct_state_space, form='modal') (with ct being a short-cut for the control package, i.e., import control as ct). The function canonical_form with parameter form set to string "modal", seems to use the underlying slycot package. And it's here where trouble starts. I get this error message:

Traceback (most recent call last):
  File "C:\Users\Tom\anaconda3\envs\control-engineering\Lib\site-packages\control\canonical.py", line 328, in _bdschur_condmax_search
    from slycot import mb03rd
  File "C:\Users\Tom\anaconda3\envs\control-engineering\Lib\site-packages\slycot\__init__.py", line 16, in <module>
    from .analysis import ab01nd, ab05md, ab05nd, ab07nd, ab08nd, ab08nz
  File "C:\Users\Tom\anaconda3\envs\control-engineering\Lib\site-packages\slycot\analysis.py", line 22, in <module>
    from . import _wrapper
ImportError: DLL load failed while importing _wrapper: Kan opgegeven module niet vinden.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Tom\PycharmProjects\control-engineering\tryouts\tryout_08.py", line 7, in <module>
    ss = ss.reform('parallel')
         ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Tom\PycharmProjects\control-engineering\python_control\core\state_space.py", line 268, in reform
    ct_ss, _ = ct.canonical_form(self._ct_state_space, form='modal')
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Tom\anaconda3\envs\control-engineering\Lib\site-packages\control\canonical.py", line 66, in canonical_form
    return modal_form(xsys)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Tom\anaconda3\envs\control-engineering\Lib\site-packages\control\canonical.py", line 522, in modal_form
    amodal, tmodal, _ = bdschur(xsys.A, condmax=condmax, sort=bd_sort)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Tom\anaconda3\envs\control-engineering\Lib\site-packages\control\canonical.py", line 449, in bdschur
    amodal, tmodal, blksizes, eigvals = _bdschur_condmax_search(
                                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Tom\anaconda3\envs\control-engineering\Lib\site-packages\control\canonical.py", line 330, in _bdschur_condmax_search
    raise ControlSlycot("can't find slycot module 'mb03rd'")
control.exception.ControlSlycot: can't find slycot module 'mb03rd'

I have no clue how to fix this issue myself. I tried to build slycot from source, but without success. I also found that when I install with conda install -c "conda-forge/label/cf202003" control slycot the error does not appear, but then the numbers in the matrices returned from e.g. ct.tf2ss() and ct.canonical_form() look terrible.

Some help would be very welcome.

@bnavigator
Copy link
Collaborator

Hi, this looks like another of those windows/conda install hiccups. Is your conda up to date and which python do you use?

Can you boil this down to a minimum slycot install check?

Within the control-engineering environment, can you import slycot or does it already throw a similar error? Is the dll/pyd installed correctly in the site-packages? Do you have MKL or openBLAS correctly installed? (For the latter being relevant, see #219 )

@bnavigator bnavigator added the build system Issues with compiling, linking and installing Slycot label Nov 6, 2023
@TomLXXVI
Copy link
Author

TomLXXVI commented Nov 6, 2023

I use conda 23.9.0 and for this project I use Python 3.11.6. When I import slycot in a script (import slycot), the same error occurs:

Traceback (most recent call last):
  File "C:\Users\Tom\PycharmProjects\control-engineering\tryouts\tryout_08.py", line 3, in <module>
    import slycot
  File "C:\Users\Tom\anaconda3\envs\control-engineering\Lib\site-packages\slycot\__init__.py", line 16, in <module>
    from .analysis import ab01nd, ab05md, ab05nd, ab07nd, ab08nd, ab08nz
  File "C:\Users\Tom\anaconda3\envs\control-engineering\Lib\site-packages\slycot\analysis.py", line 22, in <module>
    from . import _wrapper
ImportError: DLL load failed while importing _wrapper: Kan opgegeven module niet vinden.

The ImportError tells that the module _wrapper cannot be found. When I look in the slycot package installed in my conda environment, there is no file _wrapper present. However, there is a PYD file called _wrapper.cp311-win_amd64.pyd.

@TomLXXVI
Copy link
Author

TomLXXVI commented Nov 6, 2023

I've read issue #219. At the end pichim mentioned what worked for him:

conda update --all
conda create -n control-env-3-12 pytest numpy scipy control matplotlib ipykernel slycot python=3.12

I tried almost exactly the same, except I use the regular conda that is installed with Anaconda Navigator. So I wrote:

conda update --all
conda create -c conda-forge -n control-env-3-12 pytest numpy scipy control matplotlib ipykernel slycot pint sympy python=3.12

(I've just added channel conda-forge, and I also need pint and sympy in my project).

In this new virtual environment, called control-env-3-12, package slycot is working now (this means the ImportError has disappeared).

@bnavigator
Copy link
Collaborator

Closing as duplicate of #219.

@bnavigator bnavigator closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system Issues with compiling, linking and installing Slycot
Projects
None yet
Development

No branches or pull requests

2 participants