[spyder] need help on autocompletion

1,182 views
Skip to first unread message

爱勇王

unread,
May 23, 2012, 4:13:45 AM5/23/12
to spyd...@googlegroups.com
I'm new for spyder and pythonxy. My problem is when I'm typing code in spyder editor like this:

import numpy as np
from enthought.mayavi import mlab

then after "np." the autocompletion box pop up, but after "mlab." it didn't pop up.
Can someone give me some details solving this please?

Matt Anderson

unread,
May 23, 2012, 10:04:13 AM5/23/12
to spyd...@googlegroups.com
I have had this same issue with

from matplotlib import pylab

and possibly some other larger modules in the editor.  In the console they work immediately.  It seems like eventually I will come back to the editor and tab completion will work for it.  I will try to pay more attention to what I am experiencing and report back.




--
You received this message because you are subscribed to the Google Groups "spyder" group.
To post to this group, send email to spyd...@googlegroups.com.
To unsubscribe from this group, send email to spyderlib+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spyderlib?hl=en.

爱勇王

unread,
May 23, 2012, 10:23:02 PM5/23/12
to spyd...@googlegroups.com
Looks like there is no solution for this problem ?

2012/5/23 Matt Anderson <ma...@archangel.com>

jean-pat

unread,
May 24, 2012, 8:20:39 AM5/24/12
to spyd...@googlegroups.com
I meet the same behavior with some libs as lxml.

Jean-Patrick


Le jeudi 24 mai 2012 04:23:02 UTC+2, desktop a écrit :
Looks like there is no solution for this problem ?

2012/5/23 Matt Anderson <ma...@archangel.com>
I have had this same issue with

from matplotlib import pylab

and possibly some other larger modules in the editor.  In the console they work immediately.  It seems like eventually I will come back to the editor and tab completion will work for it.  I will try to pay more attention to what I am experiencing and report back.


On Wed, May 23, 2012 at 3:13 AM, 爱勇王 <wangai...@gmail.com> wrote:
I'm new for spyder and pythonxy. My problem is when I'm typing code in spyder editor like this:

import numpy as np
from enthought.mayavi import mlab

then after "np." the autocompletion box pop up, but after "mlab." it didn't pop up.
Can someone give me some details solving this please?

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To post to this group, send email to spyd...@googlegroups.com.
To unsubscribe from this group, send email to spyderlib+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/spyderlib?hl=en.

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To post to this group, send email to spyd...@googlegroups.com.
To unsubscribe from this group, send email to spyderlib+unsubscribe@googlegroups.com.

Matt Anderson

unread,
May 24, 2012, 11:33:15 AM5/24/12
to spyd...@googlegroups.com
Apparently, this was an error in rope that was fixed here


However, it would appear that this fix was not added to spyderlib's rope code (spyderlib\robe\...)

Specifically, if the spyderlib\rope\base\builtins _object_attributes function is changed to 

def _object_attributes(obj, parent):
    attributes = {}
    for name in dir(obj):
        if name == 'None':
            continue
        child = getattr(obj, name, None)
        if child is None:
        continue
        pyobject = None
        if inspect.isclass(child):
            pyobject = BuiltinClass(child, {}, parent=parent)
        elif inspect.isroutine(child):
            pyobject = BuiltinFunction(builtin=child, parent=parent)
        else:
            pyobject = BuiltinUnknown(builtin=child)
        attributes[name] = BuiltinName(pyobject)
    return attributes

as stated in the patch from the link...it works.

To view this discussion on the web visit https://groups.google.com/d/msg/spyderlib/-/bSTafrflPSUJ.

To post to this group, send email to spyd...@googlegroups.com.
To unsubscribe from this group, send email to spyderlib+...@googlegroups.com.

Jed Ludlow

unread,
May 24, 2012, 12:14:52 PM5/24/12
to spyd...@googlegroups.com
On Thu, May 24, 2012 at 9:33 AM, Matt Anderson <ma...@archangel.com> wrote:
Apparently, this was an error in rope that was fixed here


However, it would appear that this fix was not added to spyderlib's rope code (spyderlib\robe\...)

Specifically, if the spyderlib\rope\base\builtins _object_attributes function is changed to 

def _object_attributes(obj, parent):
    attributes = {}
    for name in dir(obj):
        if name == 'None':
            continue
        child = getattr(obj, name, None)
        if child is None:
        continue
        pyobject = None
        if inspect.isclass(child):
            pyobject = BuiltinClass(child, {}, parent=parent)
        elif inspect.isroutine(child):
            pyobject = BuiltinFunction(builtin=child, parent=parent)
        else:
            pyobject = BuiltinUnknown(builtin=child)
        attributes[name] = BuiltinName(pyobject)
    return attributes

as stated in the patch from the link...it works.


That's a great find, Matt. Would you mind creating a new issue report for this? That will make sure it doesn't get forgotten.

Pierre Raybaut

unread,
May 24, 2012, 12:36:54 PM5/24/12
to spyd...@googlegroups.com
Hi Matt,

Thanks for these interesting details.

Please keep in mind that the 'spyderlib/rope' directory you were
referring to (which is in Spyder's repository but not with the
distributed archive) is just a local copy of the rope library for
developers/advanced users usage only (i.e. people who are using Spyder
directly from a clone of its Mercurial repository). Regular users have
to install rope (as pyflakes and other dependencies) on their own from
the official package (http://pypi.python.org/pypi/rope), meaning that
'rope' is not included in Spyder: it is just one of its dependencies.

In other words, if the changeset you were referring to is already
included in the latest rope release (which is probably the case
because I just saw a new released dated from a few days ago), users
should benefit from it by upgrading their rope installation.

For Spyder developers, it means that we have to check if this new
v0.9.4 release is still compatible with 'spyderlib/rope_patch.py'. As
is, it is not because of the dumb version test "if rope.VERSION not in
('0.9.3', '0.9.2'):" on top of the main function, but we'll have to
investigate further than that.

But let's continue this discussion here (in the Issue that you have
just created):
http://code.google.com/p/spyderlib/issues/detail?id=1046

-Pierre

2012/5/24 Matt Anderson <ma...@archangel.com>:
>>>>> spyderlib+...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/spyderlib?hl=en.
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "spyder" group.
>>>> To post to this group, send email to spyd...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> spyderlib+...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/spyderlib?hl=en.
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "spyder" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/spyderlib/-/bSTafrflPSUJ.
>>
>> To post to this group, send email to spyd...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> spyderlib+...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/spyderlib?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "spyder" group.
> To post to this group, send email to spyd...@googlegroups.com.
> To unsubscribe from this group, send email to

Pierre Raybaut

unread,
May 24, 2012, 1:21:51 PM5/24/12
to spyder
Ok, this should be fixed now.
Please check and eventually comment here:
http://code.google.com/p/spyderlib/issues/detail?id=1046

-Pierre

On May 24, 6:36 pm, Pierre Raybaut <pierre.rayb...@gmail.com> wrote:
> Hi Matt,
>
> Thanks for these interesting details.
>
> Please keep in mind that the 'spyderlib/rope' directory you were
> referring to (which is in Spyder's repository but not with the
> distributed archive) is just a local copy of the rope library for
> developers/advanced users usage only (i.e. people who are using Spyder
> directly from a clone of its Mercurial repository). Regular users have
> to install rope (as pyflakes and other dependencies) on their own from
> the official package (http://pypi.python.org/pypi/rope), meaning that
> 'rope' is not included in Spyder: it is just one of its dependencies.
>
> In other words, if the changeset you were referring to is already
> included in the latest rope release (which is probably the case
> because I just saw a new released dated from a few days ago), users
> should benefit from it by upgrading their rope installation.
>
> For Spyder developers, it means that we have to check if this new
> v0.9.4 release is still compatible with 'spyderlib/rope_patch.py'. As
> is, it is not because of the dumb version test "if rope.VERSION not in
> ('0.9.3', '0.9.2'):" on top of the main function, but we'll have to
> investigate further than that.
>
> But let's continue this discussion here (in the Issue that you have
> just created):http://code.google.com/p/spyderlib/issues/detail?id=1046
>
> -Pierre
>
> 2012/5/24 Matt Anderson <m...@archangel.com>:
>
>
>
>
>
>
>
> > Apparently, this was an error in rope that was fixed here
>
> >https://bitbucket.org/agr/rope/issue/15/crashes-with-attributeerror
>
> > However, it would appear that this fix was not added to spyderlib's rope
> > code (spyderlib\robe\...)
>
> > Specifically, if the spyderlib\rope\base\builtins _object_attributes
> > function is changed to
>
> > def _object_attributes(obj, parent):
> >     attributes = {}
> >     for name in dir(obj):
> >         if name == 'None':
> >             continue
> >         child = getattr(obj, name, None)
> >         if child is None:
> >         continue
> >         pyobject = None
> >         if inspect.isclass(child):
> >             pyobject = BuiltinClass(child, {}, parent=parent)
> >         elif inspect.isroutine(child):
> >             pyobject = BuiltinFunction(builtin=child, parent=parent)
> >         else:
> >             pyobject = BuiltinUnknown(builtin=child)
> >         attributes[name] = BuiltinName(pyobject)
> >     return attributes
>
> > as stated in the patch from the link...it works.
>
> > On Thu, May 24, 2012 at 7:20 AM, jean-pat <jeanpatrick.pomm...@gmail.com>
> > wrote:
>
> >> I meet the same behavior with some libs as lxml.
>
> >> Jean-Patrick
>
> >> Le jeudi 24 mai 2012 04:23:02 UTC+2, desktop a écrit :
>
> >>> Looks like there is no solution for this problem ?
>
> >>> 2012/5/23 Matt Anderson <m...@archangel.com>
>
> >>>> I have had this same issue with
>
> >>>> from matplotlib import pylab
>
> >>>> and possibly some other larger modules in the editor.  In the console
> >>>> they work immediately.  It seems like eventually I will come back to the
> >>>> editor and tab completion will work for it.  I will try to pay more
> >>>> attention to what I am experiencing and report back.
>

爱勇王

unread,
May 24, 2012, 10:52:26 PM5/24/12
to spyd...@googlegroups.com
It's very glad to get response and excited to see someone has made it worded.
I've looked up in that new opened issue, but another error occurs.
Since it may not be related, I felt inappropriate to require help in that issue.

My error is:
In spyder's console, 
from enthought.mayavi import mlab
get a long list of error description:

>>> from enthought.mayavi import mlab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\enthought\mayavi\mlab.py", line 3, in <module>
    from mayavi.mlab import *
  File "C:\Python27\lib\site-packages\mayavi\mlab.py", line 27, in <module>
    from mayavi.tools.camera import view, roll, yaw, pitch, move
  File "C:\Python27\lib\site-packages\mayavi\tools\camera.py", line 23, in <module>
    from engine_manager import get_engine
  File "C:\Python27\lib\site-packages\mayavi\tools\engine_manager.py", line 12, in <module>
    from mayavi.preferences.api import preference_manager
  File "C:\Python27\lib\site-packages\mayavi\preferences\api.py", line 4, in <module>
    from preference_manager import preference_manager
  File "C:\Python27\lib\site-packages\mayavi\preferences\preference_manager.py", line 29, in <module>
    from traitsui.api import View, Group, Item
  File "C:\Python27\lib\site-packages\traitsui\api.py", line 35, in <module>
    from .editors.api import (ArrayEditor, BooleanEditor, ButtonEditor,
  File "C:\Python27\lib\site-packages\traitsui\editors\__init__.py", line 22, in <module>
    from .api import (toolkit, ArrayEditor, BooleanEditor, ButtonEditor,
  File "C:\Python27\lib\site-packages\traitsui\editors\api.py", line 10, in <module>
    from .code_editor import CodeEditor
  File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 36, in <module>
    class ToolkitEditorFactory ( EditorFactory ):
  File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 48, in ToolkitEditorFactory
    mark_color = Color( 0xECE9D8 )
  File "C:\Python27\lib\site-packages\traits\traits.py", line 486, in __call__
    return self.maker_function( *args, **metadata )
  File "C:\Python27\lib\site-packages\traits\traits.py", line 1182, in Color
    return ColorTrait( *args, **metadata )
  File "C:\Python27\lib\site-packages\traitsui\toolkit_traits.py", line 7, in ColorTrait
    return toolkit().color_trait( *args, **traits )
  File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 109, in toolkit
    _toolkit = _import_toolkit(ETSConfig.toolkit)
  File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 51, in _import_toolkit
    return __import__( name, globals=globals(), level=1 ).toolkit
  File "C:\Python27\lib\site-packages\traitsui\qt4\__init__.py", line 18, in <module>
    import pyface.qt
  File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 35, in <module>
    prepare_pyqt4()
  File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 17, in prepare_pyqt4
    sip.setapi('QString', 2)
ValueError: API 'QString' has already been set to version 1
>>> 

but in spyder's console, if switched to IPython interpreter, it works fine without error.
I've tested it works fine in the python interpreter under my windows xp sp3 console window.

Jed Ludlow

unread,
May 24, 2012, 11:50:32 PM5/24/12
to spyd...@googlegroups.com

Please try setting the Qt API to version 2 by doing the following in Spyder:
 
Tools..Preferences..Console..External Modules
Set the "API selection for QString and QVariant objects" pull down to "API #2"
Close the dialog with OK.

After making this setting change, open a new Python console and try importing mlab.

爱勇王

unread,
May 25, 2012, 12:35:45 AM5/25/12
to spyd...@googlegroups.com
It works! 
Thank you very much!
Now I'm going to figure out why my autocompletion still doesn't work after rope 0.9.4 installed and rope\base\buildins.py modified.

2012/5/25 Jed Ludlow <jed.l...@gmail.com>
Reply all
Reply to author
Forward
0 new messages