Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code completion breaks with Spyder 3 for modules added through the Python path manager #4141

Closed
arita37 opened this issue Feb 13, 2017 · 26 comments

Comments

@arita37
Copy link

arita37 commented Feb 13, 2017

Description

What steps will reproduce the problem?

  1. Jedi cannot starts auto-complete on custom module, some modules (numpy, pandas can auto-complete).

What is the expected output? What do you see instead?
Spyder 2.3 and Python 2.7 work well and Jedi auto-complete does not break.

Please provide any additional information below

Version and main components

  • Spyder Version: 3.0.0
  • Python Version: 2.7.12
  • Qt Versions: 5.6.0, PyQt5 5.6 on Windows

Dependencies

jedi >=0.8.1     :  0.8.1 (OK)
matplotlib >=1.0 :  1.5.3 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.3 (OK)
pandas >=0.13.1  :  0.19.2 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.5.0 :  1.3.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.5.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4 (OK)
sphinx >=0.6.6   :  1.4.6 (OK)
sympy >=0.7.3    :  1.0 (OK)


@ccordoba12
Copy link
Member

Please update Jedi to 0.9.0 and try again (Spyder doesn't work with Jedi 0.10.0 yet).

@arita37
Copy link
Author

arita37 commented Feb 15, 2017

Jedi 0.9.0 seems not working at all.

Jedi 0.8.1 works in this case:
module is inside sites-packages (like numpy)

If I add my own custom directory in the Python Path manager
and do import myModule as mm
it does not work....

It used to work with Python 2.7 and Spyder 2.3.1.....

How to investigate the break ?

@ccordoba12
Copy link
Member

Jedi 0.9.0 seems not working at all.

That's very strange. All our tests are passing with Jedi 0.9.

If I add my own custom directory in the Python Path manager
and do import myModule as mm

Thanks for the example. We'll take a look at it.

It used to work with Python 2.7 and Spyder 2.3.1

Jedi support was introduced in Spyder 2.3.3, so completions were provided by Rope, not Jedi.

@arita37
Copy link
Author

arita37 commented Feb 15, 2017

In this configuration, Jedi works well with custom packages from PythonPathManager:

Spyder 2.3.9 
The Scientific PYthon Development EnviRonment 
Win7 64bits - Anaconda
Python 2.7.12 64bits, Qt 4.8.7, PyQt4 (API v2) 4.11.4 on Windows

IPython >=1.0      :  4.2.0 (OK)
jedi >=0.8.1;<0.9.0:  0.8.1 (OK)
matplotlib >=1.0   :  1.5.1 (OK)
pandas >=0.13.1    :  0.19.2 (OK)
pep8 >=0.6         :  1.7.0 (OK)
pyflakes >=0.5.0   :  1.2.3 (OK)
pygments >=1.6     :  2.1.3 (OK)
pylint >=0.25      :  None (NOK)
qtconsole >=4.0    :  4.2.1 (OK)
rope >=0.9.2       :  0.9.4 (OK)
sphinx >=0.6.6     :  1.4.1 (OK)
sympy >=0.7.3      :  None (NOK)
zmq >=2.1.11       :  15.2.0 (OK)

@ccordoba12 ccordoba12 changed the title Jedi auto-completer breaks with Spyder 3.0 and Python 2.7 Code completion breaks with Spyder 3 for modules added through the Python path manager Feb 22, 2017
@ccordoba12 ccordoba12 added this to the v3.1.4 milestone Feb 22, 2017
@ccordoba12
Copy link
Member

@rlaverde, please take a look at this one.

@arita297
Copy link

It seems like PythonCustomPath are not loaded before the start of Jedi....
So Jedi cannot know the PythonCustompath to load the packages....

@arita37
Copy link
Author

arita37 commented Mar 1, 2017

Test is simple:
numpy package or anypackages in sites-package works well.

if you add a folder in Python Custom Folder and import a module from this folder:
does not work.

----> It seems module were not loaded in Jedi.....

@ccordoba12
Copy link
Member

We're probably not adding Spyder's PYTHONPATH to the list of paths used by Jedi.

@arita37
Copy link
Author

arita37 commented Mar 2, 2017

I found the jedi plugin :
https://github.com/spyder-ide/spyder/blob/539cb5ca584b75f0c21333de9fa7909729b423bc/spyder/utils/introspection/jedi_plugin.py

Could not find where Spyder JEDI is loading the Spyder's PYTHONPATH
Probably JEDI is launched before Spyder load custome folder.

Do you have an idea where it can be located in Spyder code (I can do a small workaround).

@arita37
Copy link
Author

arita37 commented Mar 3, 2017

In Jedi plugin,

Can we add PYTHONPath here in that part ?

    def load_plugin(self):
        """Load the Jedi introspection plugin"""
        if not programs.is_module_installed('jedi', JEDI_REQVER):
            raise ImportError('Requires Jedi %s' % JEDI_REQVER)
        jedi.settings.case_insensitive_completion = False
        for lib in ['numpy', 'matplotlib', 'pandas', 'mypackage']:
            jedi.preload_module(lib)

@ccordoba12
Copy link
Member

That's not enough if changes are made to Spyder's PYTHONPATH while it's running. @rlaverde is working now on a better solution.

@arita37
Copy link
Author

arita37 commented Mar 22, 2017 via email

@ccordoba12
Copy link
Member

👍 Glad to hear you like it :-)

@arita297
Copy link

arita297 commented Mar 22, 2017 via email

@ccordoba12
Copy link
Member

Sure I know, I just didn't know people were using it along with our Python path manager.

@arita37
Copy link
Author

arita37 commented Mar 22, 2017 via email

@capitanevs
Copy link

Sorry Guys... I am confused.

Is there an "official" solution to the issue, or not? :-)

@ccordoba12
Copy link
Member

There is, but we haven't released it yet. It will be part of Spyder 3.1.4 (our next release).

@capitanevs
Copy link

Thanks.
So for full autocompletion features the best way is to go back to Spyder2?

@ccordoba12
Copy link
Member

No, 3.1.4 will be released in a couple of days. Spyder 2 is unmaintained now.

@tenberg
Copy link

tenberg commented Jun 2, 2017

I am still having this issue running the latest Spyder version (3.1.4) through Anaconda on the latest version of OSX. Is this fixed? Anything else I can try?

@ccordoba12
Copy link
Member

You need to update Jedi to fix a previous error with that package in Anaconda.

@jpaasen
Copy link

jpaasen commented Jun 21, 2017

FYI
Had a similar issue with Spyder 3.1.4. The Spyder editor auto-complete functionality doesn't seem to care about the value of $PYTHONPATH (while the standard and IPython console does). However, when you add the same path to the PYTHONPATH manager inside Spyder it works like a charm.

@glennbaptista
Copy link

glennbaptista commented Jun 26, 2017

I have just installed a fresh Anaconda 2-4.4.0 and am unable to get intellisense (method popup) working on some objects (object.options for packages like odbc). Intellisense works completely in the python console, but not in iPython or the Spyder editor.

import pyodbc as odbc
# intellisense works here
cnxn = odbc.connect(r'Driver={SQL Server};Server=n1; Database=xyz;Trusted_Connection=yes;') 
# here onwards object method popups only work within python console - not Spyder or iPython
cursor = cnxn.cursor() # intellisense only works on python console
cursor.execute('Select....') # intellisense only works on python console

I've added the $PYTHONPATH variable value inside PYTHONPATH manager as well.

Intellisense in Spyder works when the imported package is directly addressed. Is intellisense meant to work against all derived objects?

@ccordoba12
Copy link
Member

@glennbaptista, unfortunately code completion doesn't work everywhere in the Editor. This is a limitation inherent to the dynamic nature of Python, so there's little we can do about it, sorry.

@glennbaptista
Copy link

glennbaptista commented Jun 26, 2017

Thank you Carlos. That aspect (partial code completion) was not clear from all the trails I googled on this problem. Most seemed to find a fix and so I uninstalled everything and reinstalled the latest anaconda-python in a futile attempt :). It appears that if the object class is not directly known, no attempt is made to precompile and determine it's class. Thanks you once again for the time you take in all the threads to answer all the queries so completely - it really does help everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants