`ipython` tab autocomplete does not work on imported module

后端 未结 14 1804
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 21:10

Tab completion on IPython seems not to be working. For example,

import numpy
numpy.

simply adds a tab.

import nu         


        
相关标签:
14条回答
  • 2020-11-29 21:30

    As of right now, on a OSX, pip installed ipython doesn't give tab completion, pyreadline release.py is busted .. what WFM:

    easy_install ipython readline
    

    YMMV.

    0 讨论(0)
  • 2020-11-29 21:31

    pip told me I had pyreadline version 1.7.1 installed

    C:\Users\me>pip freeze | grep readline
    pyreadline==1.7.1
    

    Upgrading pyreadline fixed it for me:

    C:\Users\me>pip install --upgrade pyreadline
    
    C:\Users\me>pip freeze | grep readline
    pyreadline==2.0
    
    0 讨论(0)
  • 2020-11-29 21:34

    Downgrading iPython did the trick.

    pip install --upgrade ipython==5.8.0
    
    0 讨论(0)
  • 2020-11-29 21:34

    Someone else in StackOverflow posted this link: http://www.vankouteren.eu/blog/2009/06/getting-ipython-readline-and-auto-completion-to-work-on-mac-os-x/

    Its basicly easy_install readline than discover where the readline egg got installed and edit the ipython bin script to use this readline:

    1. Install the "official" readline: easy_install readline
    2. Discover where it is. Look at /Library/Python/site-packages/readline-*.egg or in your Virtualenv counterpart
    3. Discover where ipython bin is: which ipython
    4. Add ONE LINE to this file, adding the readline egg path right after import sys line.

    My virtualenved ipython bin script got working as follow:

    #!/Users/alanjds/src/git/cervejeiras/venv/cervejeiras-lfs/bin/python
    # EASY-INSTALL-ENTRY-SCRIPT: 'ipython==0.13.1','console_scripts','ipython'
    __requires__ = 'ipython==0.13.1'
    import sys
    
    ### ONLY LINE ADDED:
    sys.path.insert(0, '/Users/alanjds/src/git/cervejeiras/venv/cervejeiras-lfs/lib/python2.6/site-packages/readline-6.2.4.1-py2.6-macosx-10.6-fat.egg')
    ####
    
    from pkg_resources import load_entry_point
    
    if __name__ == '__main__':
        sys.exit(
            load_entry_point('ipython==0.13.1', 'console_scripts', 'ipython')()
        )
    
    0 讨论(0)
  • 2020-11-29 21:34

    If you use Jupyter notebook and you still did get Tab auto-complete working after you tried all the steps suggested in the post here, you might want to check if you are trying to use the Tab auto-completion within a function definition. Ifyour import statements are part of the function such as below, you will not get the Tab auto-completion. You need to put the import statements outside the function and also execute them once before asking for auto-completion on the packages.

    def myfunction():
        import pandas as pd
        import numpy as np
    
        a = pd.DataFrame(np.random.normal(1,3, (4,4))
        return a
    
    0 讨论(0)
  • 2020-11-29 21:36

    Pyreadline is needed by ipython. Install pyreadline. This was done in Windows 7. Get pyreadline zip, pyreadline-master.zip, unzip. In powershell change directory into uzipped pyreadline, make sure python is set in Path, and enter commandpython setup.py install This will intall pyreadline in C:\Python27\Lib\site-packages

    0 讨论(0)
提交回复
热议问题