Complete all-around vim-Python and set Python Environment Variables

Source: Internet
Author: User

Vim's omnipotent completion for python can be used normally for all module libraries that come with python, but some custom modules do not work. This is

Because the current Vim process needs to find the corresponding module and perform import and analysis to obtain the complete vocabulary, VIM does not know the path to some custom modules.

This is found here, so the completion function will become invalid. This is related to the python PATH environment variable. There are several ways to solve this problem.

 

1. Modify the pythonpath environment variable pythonpath = $ home/libs/python to assign the directory of the module to the variable pythonpath. Separate multiple directories with colons,

 

 

If you use Vim on a terminal, you can modify it ~ /. Bashrc file. You can modify it if gvim is used ~ /. Profile file, so that Vim is enabled by default.

Set the pythonpath variable.

2. Add and modify the python path in the vim startup settings file.Code: File repair ~ /. Vimrc Add the following line

Let $ pythonpath. = ":/home/gnolux/develop/Python/google_appengine/lib/webob"

3. Use the specific Loading Method of Python itself:

You can add a file with the. PTH extension under the. Local/lib/python2.6/Site-packages directory. Each line in the file is a Module Directory, which is automatically started when python is started.

Find all. PTH files in this directory, parse the file content, and add the directory as the module search path.

 

The first method is troublesome, and you need to restart the terminal if you want to take effect. The second method is acceptable for small projects that can be manually added. The third method is recommended.

In many cases, we can use commands to automatically add related directories to the PTH file, as shown below:

 

 

 

Find ~ /. Local/lib-type D-print> ~ /. Local/lib/python2.6/Site-packages/python_path.pth

 

Add all directories under the. Local/lib directory to the path. PTH file, because I have put my own modules or third-party modules under the lib directory. For details, see the help of the find command.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.