44

I'm having a problem getting my local variables autocompleted. This is a very basic functionality which I'm sure it should support. When I'm starting to write a variable name which was already declared, and press TAB (this is the default shortcut), I get nothing. Is this a bug?

user3731622
  • 4,844
  • 8
  • 45
  • 84
idoda
  • 6,248
  • 10
  • 39
  • 52

5 Answers5

88

(Spyder dev here) Spyder does complete local variables but to have this functionality you need to install a library called rope. You can do it by running this command in a terminal

pip install rope

If you use Python 3 this command needs to be

pip install rope_py3k

Besides, code completion on the Editor works now with both Ctrl+Space and with Tab.

Edit: Updated answer for the Spyder version 2.3.0.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
  • Great! just finished seeing your youtube video, great work guys! I think spyder is great, would really appriciate if you could support more types in the variable explorer, such as pandas series and dataframes, multi dimensional arrays and so on. – idoda Aug 05 '13 at 08:24
  • I'm glad you saw and enjoyed my video! Dataframes and Series in the variable explorer are also planned for a future release, I just need to find the time to do it :) – Carlos Cordoba Aug 05 '13 at 14:40
  • Take a look at this [issue](http://http://code.google.com/p/spyderlib/issues/detail?id=1160). It has some starting code and ideas from which you can start off. If you questions or need orientation, please write there. I really hope you can help us with this :) – Carlos Cordoba Aug 20 '13 at 13:48
  • Yep, sorry. This is the [right link](http://code.google.com/p/spyderlib/issues/detail?id=1160) – Carlos Cordoba Aug 26 '13 at 19:41
  • I'm on a Mac. How do I make sure when doing pip install I'm really installing it for Spyder? Right now my pip comes from miniconda (Python 3) which will just say `Requirement already satisfied`. – huggie Jan 27 '14 at 11:55
  • Spyder is not ready for Python 3 yet. Our next version (currently in beta) will support and when that happens miniconda will do it too. – Carlos Cordoba Jan 28 '14 at 01:36
  • Spyder 2.3.1 now has a pandas dataframe and series editor and support Python 3 – Quant Sep 01 '14 at 17:46
  • Thank you very much **Carlos Cordoba**! I use `sudo pip3 install rope_py3k` instead of `sudo pip install rope_py3k` and it works too. – Manuel Ignacio López Quintero Feb 17 '15 at 17:55
  • the tab completion works when I go `pandas.` but when i try to access the methods in a variable for e.g. df., it does not work . . . am I doing something wrong or this is not yet a feature? – vagabond Mar 23 '17 at 21:44
  • @vagabond, please see http://stackoverflow.com/a/42789884/438386 for an explanation. – Carlos Cordoba Mar 23 '17 at 22:35
  • @CarlosCordoba thanks! i'll have to create a github issue then! – vagabond Mar 24 '17 at 13:44
  • 1
    As of now, rope_py3k is deprecated and rope is compatible with Python 3. So you should just go with `pip install rope` – Adrien Mau Sep 01 '22 at 10:27
4

Another hint:

If you want to customize the shortcut (for example, your 'ctrl+space' is already occupied), try

Tools--Preferences--Keyboard shortcuts--code completion

you can change it to whatever you want

fstang
  • 5,607
  • 4
  • 25
  • 26
  • Another option (available only in the upcoming `2.3` version) is that you can use the `Tab` key to do code completions in the Editor – Carlos Cordoba Jun 29 '14 at 00:27
4

Idoda, I made a little guide to install Python for scientific computing on Ubuntu or Debian from their repositories. I tested correctly using Python 3 on Ubuntu 14.04 LTS.

It summarizes as follows. First, install the interpreter and the package manager:

sudo apt-get install python3 python3-pip 

Now install the Spyder's IDE:

sudo apt-get install spyder3

Thanks to Carlos Cordoba's advice, if you want to enjoy the autocomplete execute:

sudo pip3 install rope_py3k

Finally, open Spider and check if the autocomplete works rightly.

4

In my case, with the command conda install spyder, the installation process prompted me with the following...

The following NEW packages will be INSTALLED:

rope:   0.10.5-py36_0 conda-forge
spyder: 3.1.4-py36_0  conda-forge

Proceed ([y]/n)? y

I want to point out that my anaconda installation is for python 3. After this auto-completion was working. I'm utilizing OS X El Capitan.

redeemefy
  • 4,521
  • 6
  • 36
  • 51
2

Usually, ctrl+space is set to code completion in Tools -> Preferences -> Keyboard shortcuts -> code completion We have the option to change it to another shortcut.

J11
  • 455
  • 4
  • 8