Can't import package from cvxopt

1,977 views
Skip to first unread message

bonoops

unread,
Dec 24, 2008, 12:25:06 AM12/24/08
to CVXOPT
Hi all,

I got some problems on using cvxopt.

My system is Ubuntu 8.10

I install cvxopt in three way:
1 . from synaptic
2. build from sources: python setup.py install
3. sudo apt-get build-dep python-cvxopt

however, no matter which way I chose, in Python commnad line, I can't
import the packages from cvxopt

>>> from cvxopt import matrix
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/PIL/__init__.py", line 5, in
<module>
# package placeholder
ImportError: No module named base
>>>

Please help me. Many thanks!

Joachim Dahl

unread,
Dec 24, 2008, 2:44:45 AM12/24/08
to cvx...@googlegroups.com
The version of CVXOPT in Ubuntu 8.10 is 1.0, and your example

>>> from cvxopt import matrix

is only valid in the in latest release (1.1). Alternatively, you can
write

>>> from cvxopt.base import matrix

or you can install the latest version by compiling it from source. In that
case you should probably uninstall your current version of CVXOPT first.

Note, that approach 3. below doesn't install CVXOPT; it only installs the
necessary dependencies for building the CVXOPT packages in Ubuntu.

Joachim

bon felips

unread,
Dec 24, 2008, 8:37:03 AM12/24/08
to cvx...@googlegroups.com
Hi Joachim,

Yes, thank you very much for you quick reply.

However, the problem is as follow:

I built it from source using version 1.1,  when I enter

>>> from cvxopt import matrix

in Python command line, I get the following output:


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/PIL/__init__.py", line 5, in <module>
    # package placeholder
ImportError: No module named base

it seems that something wrong in __init__.py file...

if I would like to remove cvxopt 1.1 built from source, how can I do this?

Thanks again!
--
Regards,

Sihong

Joachim Dahl

unread,
Dec 25, 2008, 2:52:56 AM12/25/08
to cvx...@googlegroups.com
normally the installation ends up in

/usr/lib/python2.5/site-packages

or

/home/user/lib/python.

Perhaps the problem is caused by having mixed versions of CVXOPT
installed in the same directory,  but the error message also mentions 'PIL',  which is strange.

bon felips

unread,
Dec 25, 2008, 5:01:13 AM12/25/08
to cvx...@googlegroups.com
I installed cvxopt 0.9 from sources in Ubuntu 7.10, everything is OK. Is it the problem of different kernel?
--
Regards,

Sihong

Joachim Dahl

unread,
Dec 25, 2008, 5:07:06 AM12/25/08
to cvx...@googlegroups.com
No, the kernel doesn't matter. I suspect the problem is caused by
installing
several versions of CVXOPT within in the same directory; if you
completely remove
CVXOPT and then reinstall either version of CVXOPT, then I am confident
it works.

And if you install an older version (than v1.1) then you must write
>>> from cvxopt.base import matrix

instead of
>>> from cvxopt import matrix

Joachim

bon felips

unread,
Dec 25, 2008, 5:41:10 AM12/25/08
to cvx...@googlegroups.com
Hi,

Would you please tell me how to "completely" remove the previously installed cvxopt?
--
Regards,

Sihong

Joachim Dahl

unread,
Dec 25, 2008, 5:54:35 AM12/25/08
to cvx...@googlegroups.com
1) You should first use your package manager to remove the versions you
installed using it.

2) If you manually compiled and installed CVXOPT on top of the version
installed by
the package manager, you should remove that directory manually:
$ sudo rm -rf /usr/lib/python2.5/site-packages/cvxopt*

3) If you manually compiled and installed CVXOPT somewhere else, you
should remove
that also, for example,
$ rm -rf ~/lib/python/cvxopt*


bon felips wrote:
> Hi,
>
> Would you please tell me how to "completely" remove the previously
> installed cvxopt?
>
> On Thu, Dec 25, 2008 at 6:07 PM, Joachim Dahl <dahl.j...@gmail.com
> <mailto:dahl.j...@gmail.com>> wrote:
>
>
> No, the kernel doesn't matter. I suspect the problem is caused by
> installing
> several versions of CVXOPT within in the same directory; if you
> completely remove
> CVXOPT and then reinstall either version of CVXOPT, then I am
> confident
> it works.
>
> And if you install an older version (than v1.1) then you must write
> >>> from cvxopt.base import matrix
>
> instead of
> >>> from cvxopt import matrix
>
> Joachim
>
> bon felips wrote:
> > I installed cvxopt 0.9 from sources in Ubuntu 7.10, everything
> is OK.
> > Is it the problem of different kernel?
> >
> > On Thu, Dec 25, 2008 at 3:52 PM, Joachim Dahl
> <dahl.j...@gmail.com <mailto:dahl.j...@gmail.com>
> > <mailto:dahl.j...@gmail.com <mailto:dahl.j...@gmail.com>>>
> wrote:
> >
> > normally the installation ends up in
> >
> >
> > /usr/lib/python2.5/site-packages
> >
> > or
> >
> > /home/user/lib/python.
> >
> > Perhaps the problem is caused by having mixed versions of CVXOPT
> > installed in the same directory, but the error message also
> > mentions 'PIL', which is strange.
> >
> > On Wed, Dec 24, 2008 at 2:37 PM, bon felips
> <bon...@gmail.com <mailto:bon...@gmail.com>
> > <mailto:bon...@gmail.com <mailto:bon...@gmail.com>>> wrote:
> >
> > Hi Joachim,
> >
> > Yes, thank you very much for you quick reply.
> >
> > However, the problem is as follow:
> >
> > I built it from source using version 1.1, when I enter
> >
> > >>> from cvxopt import matrix
> >
> > in Python command line, I get the following output:
> >
> >
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > File "/usr/lib/python2.5/site-packages/PIL/__init__.py",
> > line 5, in <module>
> > # package placeholder
> > ImportError: No module named base
> >
> > it seems that something wrong in __init__.py file...
> >
> > if I would like to remove cvxopt 1.1 built from source, how
> > can I do this?
> >
> > Thanks again!
> >
> >
> > On Wed, Dec 24, 2008 at 3:44 PM, Joachim Dahl
> > <dahl.j...@gmail.com <mailto:dahl.j...@gmail.com>
> <mailto:dahl.j...@gmail.com <mailto:dahl.j...@gmail.com>>>
Reply all
Reply to author
Forward
0 new messages