Jedi Vim Python subclasses are not detected on TAB-completion

混江龙づ霸主 提交于 2019-11-29 12:39:11

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!