Search code examples
pythonvimsyntasticflake8

How to configure paths to import from for flake8 in syntastic


I configured flake8 as the python checker in syntastic plugin. Problem is my project has some extra paths added to sys.path at runtime. I need somewhere to configure those paths, otherwise the checker will keep complaining [F0401] Unable to import 'module'. So where can I do this.

UPDATE

Turns out that it is pylint checker that complains the import error. flake8 seems do not care about this. Following is the output of flake8. And the solution to fix this for pylint plz refer to this question:PyLint "Unable to import" error - how to set PYTHONPATH?

$ flake8 TestListPage.py
TestListPage.py:7:1: W191 indentation contains tabs
TestListPage.py:8:1: W191 indentation contains tabs
TestListPage.py:9:1: W191 indentation contains tabs
TestListPage.py:10:1: W191 indentation contains tabs
TestListPage.py:12:1: W191 indentation contains tabs
TestListPage.py:13:1: W191 indentation contains tabs
TestListPage.py:15:1: W191 indentation contains tabs
TestListPage.py:16:1: W191 indentation contains tabs
TestListPage.py:18:1: W191 indentation contains tabs

Also the answer of @lcd047 may help for other plugins using the python interpreter. But it does not fix the pylint error.

$ echo $PYTHONPATH
/cygdrive/c/---------------/
$ pylint TestListPage.py
************* Module TestListPage
W:  7,0: Found indentation with tabs instead of spaces
...
C: 45,0: Line too long (95/80)
...
C:  1,0: Missing docstring
F:  3,0: Unable to import 'guis'

Solution

  • Set the environment variable PYTHONPATH either before running vim:

    PYTHONPATH='/some/dir:/some/other/dir' vim /path/to/your/file.py
    

    or from Vim itself:

    let $PYTHONPATH='/some/dir:/some/other/dir'