Problems with using cvxpy in Spyder IDE on Mac, Anaconda distribution

450 views
Skip to first unread message

YK

unread,
Jul 17, 2015, 12:30:53 PM7/17/15
to cv...@googlegroups.com
Hi,

  I installed cvxpy following the instructions in this link: http://cvxpy.readthedocs.org/en/latest/install/index.html . When I tried to use cvxpy in Spyder IDE, Anaconda distribution, on Mac, I got an error "AttributeError: 'module' object has no attribute 'sum_squares' ". I was looking at the L1 trend filtering example: http://nbviewer.ipython.org/github/cvxgrp/cvxpy/blob/master/examples/notebooks/WWW/l1_trend_filter.ipynb . The following short script also gives me the same error message in Spyder:

import numpy as np
import cvxpy as cvx

y = np.arange(1,5, 0.1)
x = cvx.Variable(len(y))
obj = cvx.Minimize(cvx.sum_squares(y-x))

The error message appears after this line. 

If I do not use Spyder, but just use the normal python started from terminal, the error does not appear and cvxpy runs normally, but I would prefer to use cvxpy in Spyder if possible. 

Can I find out if there is some way to resolve this error in Spyder please? Thank you.

Regards
yk

Steven Diamond

unread,
Jul 17, 2015, 2:41:38 PM7/17/15
to cv...@googlegroups.com
My guess is Spyder is using the wrong version of CVXPY. What do you get when you run ``cvxpy.__version__`` in Spyder? 

If this is the problem, you need to figure out how to update the cvxpy version that spyder is using.

YK

unread,
Jul 18, 2015, 9:33:23 AM7/18/15
to cv...@googlegroups.com
Thanks. The problem is very similar to what you mentioned. Turns out that I had a very old version of cvxpy installed on my Mac, in the original python library. When I installed the Anaconda distribution and use the spyder IDE that came with Anaconda, spyder imported the old version of cvxpy rather than the new version that was installed in the Anaconda library. Removing the search path in spyder to the original python library seems to make it work now. 

Regards
yk 
Reply all
Reply to author
Forward
0 new messages