cvxgrp/qcqp

ImportError: cannot import name 'QuadCoeffExtractor'

Closed this issue · 9 comments

The line from qcqp import * results in the error

ImportError: cannot import name 'QuadCoeffExtractor'

The culprit seems to be the line

from cvxpy.utilities import QuadCoeffExtractor

cvxpy was installed from conda (as the pip install is not recommended anymore via https://github.com/cvxgrp/cvxpy/issues/323 ), qcqp was installed as pip install --upgrade cvxpy.

Let me know if you need more information, thanks!

Update:

it seems that QuadCoeffExtractor was rewritten/ renamed to coeff_extractor, so I replaced this inside utilities.py, so it seems to work (but it might not, since the functionality of coeff_extractor might have been changed too?).

new line:

extractor = coeff_extractor(*get_id_map(prob.variables()))

After doing this, the next error occurs in the line (from the example)

obj = cvx.sum_squares(A*x - b)

with error
ValueError: Cannot broadcast dimensions (15,) (15, 1)

changing b = randn(m, 1) to b = randn(m) fixes the above problem.

Then another problem occurs:

AttributeError: 'Zero' object has no attribute '_expr', which can be fixed by replacing _expr by expr in utilities.py (or can it? I may make matters worse that way).

However, this causes the (former quadextractor, now coeff_extractor ) to cause the error

IndexError: invalid index to scalar variable. from the get_id_map and the errors continue once I try to "fix" the lines.

It seems, the qcqp version I have works probably for an older version of cvxpy, or I made an installation mistake?

I also met this trouble.

I am having the exact same problems. Changing some code in get_id_map to handle objects that are not matrices gets rid of some errors, and so does writing

from cvxpy.utilities.coeff_extractor import CoeffExtractor

Currently getting stuck at:
File "/Users/amolinap/anaconda3/envs/optimization/lib/python3.6/site-packages/qcqp/utilities.py", line 336, in get_qcqp_form extractor = CoeffExtractor(*get_id_map(prob.variables())) TypeError: __init__() takes 2 positional arguments but 3 were given

Installing cvxpy and then qcqp in a clean Anaconda environment.

thanks for the report. I'll look into it as soon as I can. meanwhile, could you provide the version numbers of python, anaconda, cvxpy, and qcqp? this will make it easier for me to reproduce the error.

Thanks for the answer! Just updated the previous comment with some more details of the troubleshooting. Re:versions, I am using anaconda 3.7.0 (the latest one as of this morning), which came with python 3.6.5.final.0. The package versions are cvxpy 1.0.6 and qcqp 0.8.2. The anaconda version came with conda 4.5.4 and conda-build 3.10.5, in case it's relevant.

Same here qcqp==0.8.2, cvxpy==1.0.6

qcqp==0.8.2
cvxpy==1.0.6
anaconda-client==1.6.14
conda==4.5.8

Python == 3.6

Same issue:
cvxpy: 1.0.6
qcqp: 0.8.2
anaconda/conda: None
Python: 2.7.6
OS: Ubuntu 16.04

Is there a stable/working combination that I can revert back to?

I'm trying to get in touch with the people who have rewritten the utility classes QCQP was relying on. the fix is going to take some more time, but I think downgrading cvxpy to <1.0 can work. sorry for the inconveniences.

I had another look at the problem, and confirmed that QCQP won't work with cvxpy 1.0 without significant editing. at this point I don't know when I can make the package compatible with the 1.0 version, but I checked that it indeed works with the older version of cvxpy (v0.4 branch). I have updated the installation guide in the readme file. appreciate everyone's patience.