spyder: Code completion in the Editor doesn't work properly, unlike in the IPython console

From marushk…@gmail.com on 2015-02-06T08:44:55Z

Spyder Version: 2.4.0dev Python Version: 3.4.1 Qt Version : 4.8.6, PyQt4 (API v2) 4.10.4 on Windows pyflakes >=0.6.0: 0.7.3 (OK) pep8 >=0.6 : 1.4.6 (OK) IPython >=1.0 : 2.3.1 (OK) zmq >=2.1.11 : 14.4.1 (OK) pygments >=1.6 : 2.0.1 (OK) pandas >=0.13.1 : 0.14.1 (OK) sphinx >=0.6.6 : 1.2.3 (OK) jedi >=0.8.1 : 0.8.1-final0 (OK) rope >=0.9.2 : 0.9.4-1 (OK) matplotlib >=1.0: 1.4.0 (OK) sympy >=0.7.0 : 0.7.5 (OK) pylint >=0.25 : 1.4.1 (OK)

What steps will reproduce the problem?

  1. Import module
  2. Create a local variable using class from the module
  3. Write the name of the variable, put the dot and call the autocompletion (TAB or CTRL+SPACE)

What is the expected output? What do you see instead?

In the editor: I expected popup box with available methods and members, but it don’t appear. In the console: All is OK.

Please provide any additional information below

I tried numpy and cv2:

import numpy as np # 'imp' completion works, 'num' completion works
arr = np.array([1,2,3,4,5]) # 'np.' completion works
arr. # completion don't work 

import cv2
cap = cv2.VideoCapture(0) # 'cv2.' completion works
cap. # completion don't work 

Same code in console work fine. I use Anaconda and last spyder version from bitbucket and run it like follow: “python bootstrap.py --debug” When I call completion for variable arr. or cap. I got next debug output: completions request: [] completions request from jedi complete: “[]” in 0.1 sec completions request from rope complete: “[]” in 0.2 sec got timeout

_Original issue: http://code.google.com/p/spyderlib/issues/detail?id=2162_

About this issue

  • Original URL
  • State: open
  • Created 12 years ago
  • Comments: 44 (21 by maintainers)

Most upvoted comments

@stonebig @bcolsen removing enum34 did the trick.

This is really cool!! Thanks a lot for taking the time to look into it.

It’d be great if you could have a patch for Spyder before January 7, which is the feature freeze date for Spyder 3.1 😃

Sorry for hijacking this issue more…but I wanted to share my success. I got compiled objects in Jedi to return numpydoc return types. So now np.array() (and most of the other numpy stuff) now completes:

screenshot from 2016-12-10 00-29-33

The code is still a little messy but I’m going to attempt to make a usable Jedi branch with the code and maybe another patch for Spyder.

is this a possible solution ? (“pip uninstall enum34” , as the module is wrongly required per some pymc3 wheels on python >= 3.4) https://github.com/spyder-ide/spyder/issues/5071#issue-253179855

Please see my comment immediately above yours.

@stonebig Yes! Removing enum34 does work!

Great! Thanks a lot for looking at it 😃

Patching Jedi. Good idea. I can give that a shot. I should have some time around the end of the month.

I also think I’m close to a hack on Jedi to return types for compiled functions like np.array and scipy stuff, but I’ll start with a simple pull first.

I didn’t write this code but this jedi pull request actually implements parsing the numpydoc doc strings for call return types: davidhalter/jedi#796 https://github.com/Erotemic/jedi/tree/parse_google_docstr

After some effort, I was able to get this: import jedi; jedi.Script('import numpy; a = numpy.ones().m').completions() to actually return something: screenshot from 2016-11-28 00-11-37

Things I did to make this work(Edit: This is unnecessary. See my comment below)

  1. I’m using Anaconda on Ubuntu and Python 3.5
  2. I had to change the doc string for numpy.ones from out : ndarray to out : numpy.ndarray. adarray isn’t a type known to jedi.
  3. I was only able to get this to work by importing the jedi code from the source folder. The installed (python setup.py install) versions didn’t work. As a result I couldn’t get it to work with Spyder. I’m probably doing something wring here.
  4. I have to run it 3 times(it’s consistent too). According to the Jedi debug function the first two times jedi doesn’t even find the numpy.ones function.

My set up: jedi >=0.8.1 : 0.10.0 (OK) matplotlib >=1.0 : 1.5.3 (OK) nbconvert >=4.0 : 4.2.0 (OK) numpy >=1.7 : 1.11.1 (OK) pandas >=0.13.1 : 0.18.1 (OK) pep8 >=0.6 : 1.7.0 (OK) psutil >=0.3 : 4.3.1 (OK) pyflakes >=0.6.0 : 1.3.0 (OK) pygments >=2.0 : 2.1.3 (OK) pylint >=0.25 : 1.6.4 (OK) qtconsole >=4.2.0: 4.2.1 (OK) rope >=0.9.4 : 0.9.4-1 (OK) sphinx >=0.6.6 : 1.4.6 (OK) sympy >=0.7.3 : 1.0 (OK)

I don’t know if this is useful but I spent a couple hours on it so I might as well document it here to see if anyone else has better luck. I might try out matplotlib in the future.

Completions for DataFrames will work in Spyder 3.0. For other types we will need to implement the solution proposed here, which is not so easy 😉