osqp / osqp

The Operator Splitting QP Solver
https://osqp.org
Apache License 2.0
1.67k stars 355 forks source link

Encountered unexpected exception importing solver OSQP: ImportError('DLL load failed while importing qdldl: #493

Open testMonkey02 opened 1 year ago

testMonkey02 commented 1 year ago

Encountered unexpected exception importing solver OSQP: ImportError('DLL load failed while importing qdldl:

Version: windows 10 anaconda3 CVXPY Version: 1.2.2 OSQP: 0.6.2post0 qdldl: 0.1.5post2

I just install cvxpy and mosek by "conda install" according to the cvxpy.org. When I use it to solve a problem, it reports that problem. However, using same version on my M1 mac and ubuntu 18.04 will not.

testMonkey02 commented 1 year ago

i reinstall libqdldl=0.1.5, then the problem is solved.

uricohen commented 1 year ago

I have the same problem with version libqdldl=0.1.5, and the problem persists. Updating its dependencies through conda update libqdldl does not help either.

fortunewalla commented 1 year ago

[solved?] (see towards end) I have the same problem. I tried the above conda update but it says "all requested packages are already installed."

>>> qutip.about()

QuTiP: Quantum Toolbox in Python
================================
Copyright (c) QuTiP team 2011 and later.
Current admin team: Alexander Pitchford, Nathan Shammah, Shahnawaz Ahmed, Neill Lambert, Eric Giguère, Boxi Li, Jake Lishman, Simon Cross and Asier Galicia.
Board members: Daniel Burgarth, Robert Johansson, Anton F. Kockum, Franco Nori and Will Zeng.
Original developers: R. J. Johansson & P. D. Nation.
Previous lead developers: Chris Granade & A. Grimsmo.
Currently developed through wide collaboration. See https://github.com/qutip for details.

QuTiP Version:      4.7.1
Numpy Version:      1.23.5
Scipy Version:      1.9.3
Cython Version:     0.29.32
Matplotlib Version: 3.6.2
Python Version:     3.9.15
Number of CPUs:     2
BLAS Info:          Generic
OPENMP Installed:   False
INTEL MKL Ext:      False
Platform Info:      Windows (AMD64)
Installation path:  C:\sw\envs\qutip\lib\site-packages\qutip
================================================================================
Please cite QuTiP in your publication.
================================================================================
For your convenience a bibtex reference can be easily generated using `qutip.cite()`
>>> import osqp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\sw\envs\qutip\lib\site-packages\osqp\__init__.py", line 1, in <module>
    from osqp.interface import OSQP
  File "C:\sw\envs\qutip\lib\site-packages\osqp\interface.py", line 14, in <module>
    import qdldl
ImportError: DLL load failed while importing qdldl: The specified module could not be found.
>>> exit()

Should I try to update using pip instead of conda?

===========

[solved?]

I went ahead and took a chance to install through pip.

G:\sw\mm>pip install --upgrade qdldl
Requirement already satisfied: qdldl in C:\sw\envs\qutip\lib\site-packages (0.1.5.post2)
Collecting qdldl
  Downloading qdldl-0.1.5.post3-cp39-cp39-win_amd64.whl (83 kB)
     ---------------------------------------- 83.2/83.2 kB 389.9 kB/s eta 0:00:00
Requirement already satisfied: scipy>=0.13.2 in C:\sw\envs\qutip\lib\site-packages (from qdldl) (1.9.3)
Requirement already satisfied: numpy>=1.7 in C:\sw\envs\qutip\lib\site-packages (from qdldl) (1.23.5)
Installing collected packages: qdldl
  Attempting uninstall: qdldl
    Found existing installation: qdldl 0.1.5.post2
    Uninstalling qdldl-0.1.5.post2:
      Successfully uninstalled qdldl-0.1.5.post2
Successfully installed qdldl-0.1.5.post3

Now, at least that error is no longer displaying.

(qutip) C:\sw\>python -c "import qutip; print(qutip.__version__)"
4.7.1

(qutip) C:\sw\>python -c "import osqp;"

(qutip) C:\sw\>
spixap commented 11 months ago

I had a similar problem with exactly the same version (qdldl-0.1.5.post2) and fortunewalla proposed solution worked perfectly. Initially, qdldl was installed along with the cvxpy 1.3.2 installation through conda-forge and that may be the problem. The latest version found with pip (qdldl-0.1.7.post0) is working and fixes the problem.