首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在语法中配置从flake8导入的路径

如何在语法中配置从flake8导入的路径
EN

Stack Overflow用户
提问于 2015-06-04 05:23:33
回答 1查看 2.6K关注 0票数 0

我将flake8配置为syntastic插件中的python检查器。问题是我的项目在运行时向sys.path添加了一些额外的路径。我需要一些地方来配置这些路径,否则检查程序会一直抱怨[F0401] Unable to import 'module'。我在哪能做到这点。

更新

结果发现,抱怨导入错误的是pylint检查器。flake8似乎并不关心这个问题。以下是flake8的输出。为pylint解决这个问题的方法是:PyLint "Unable to import" error - how to set PYTHONPATH?

代码语言:javascript
复制
$ 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 047的回答可能有助于使用python解释器的其他插件。但是它没有修复pylint错误。

代码语言:javascript
复制
$ 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'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-04 05:57:45

在运行vim之前设置环境变量PYTHONPATH

代码语言:javascript
复制
PYTHONPATH='/some/dir:/some/other/dir' vim /path/to/your/file.py

或来自Vim本身:

代码语言:javascript
复制
let $PYTHONPATH='/some/dir:/some/other/dir'
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30635523

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档