Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import vim in python gives back errors

Tags:

python

vim

I read some articles about Vimscripting with python. I felt very interested. So I tried to figure out how to do vimscripting with python. But when I tried to import vim, it showed that the module vim wasn't installed. So I searched on the web, but still haven't find the module to install. I also tried pip to search automatically, still failed. Does anyone know where to find the module vim?

I am using fedora 17, and I have installed vim 7.3 and python 2.7.

Thanks in advance.

Here is the error message:

>>> import vim
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named vim
like image 364
Leon R. Wood Avatar asked Nov 20 '12 16:11

Leon R. Wood


People also ask

How do I resolve Python import errors?

Python's ImportError ( ModuleNotFoundError ) indicates that you tried to import a module that Python doesn't find. It can usually be eliminated by adding a file named __init__.py to the directory and then adding this directory to $PYTHONPATH .

Which Python does Vim use?

+python3 - Vim has built-in support for Python 3. +python - Vim has built-in support for Python 2. +python3/dyn - Vim has dynamic support for Python 3.

What is import from in python?

In Python, you use the import keyword to make code in one module available in another. Imports in Python are important for structuring your code effectively. Using imports properly will make you more productive, allowing you to reuse code while keeping your projects maintainable.


1 Answers

It doesn't seem like you need to import it, just make sure your vim is compiled with python support. Check this using vim --version | grep +python. Further, it seems that the vim module is imported automatically when in vim, rendering your import line unnecessary.

like image 199
hd1 Avatar answered Sep 28 '22 07:09

hd1