Jedi Vim Python subclasses are not detected on TAB-completion

后端 未结 2 1281
梦毁少年i
梦毁少年i 2020-12-20 02:22

The issue is on Arch (1) & Debian Jessie (2) where:

1.

> uname -r
4.0.5-1-ARCH
> echo $PYTHONPATH
/usr/lib/python2.7/
相关标签:
2条回答
  • 2020-12-20 02:56

    Old question, but I've found an alternative to amending sys.path if you are using virtual environments.

    You can instead create a .pth (https://docs.python.org/2/library/site.html) file in your <virtualenv>/lib/<python>/site-packages folder that points to the root of your source e.g. if my source was in /user/123/python-proj/source folder and my virtual env was in the /user/123/python-proj/venv folder

    echo '/user/123/python-proj/source > /user/123/python-proj/venv/lib/python3.5/site-packages/my-source.pth'
    

    Make sure you activate the virtual env first, then launch vim and jedi should be able to find your code.

    0 讨论(0)
  • 2020-12-20 03:17

    I just realized that I did an error due to my incomprehension. I was trying to import the following way:

    Which was natural when I used ipython with tab completion like this:

    That is a wrong way to import a module in a python script. This is the right way:

    Finally, the Jedi-Vim plug-in works perfectly. In case of uncertainty related to unavailable imports you can verify your imports with:

    :python import sys; print(sys.path)
    

    And then add the missing directories during the run time to test if their absence was causing the issue.

    :python import sys; sys.path.append("/path/to/dir")
    

    In my case the os.py was located at /usr/lib/python2.7/.

    I hope this clarifies this for the future Jedi-Vim users.

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