Anaconda在Sublime Text设置中忽略“extra_paths”

时间:2016-07-06 16:26:35

标签: python sublimetext3 sublime-text-plugin sublime-anaconda

我正在尝试将Sublime Text 3配置为我的Python开发IDE,虽然我已经阅读了文档,但我仍然无法使用Anaconda.sublime-settings文件导入额外的库。根据我的阅读,它应该像在Anaconda.sublime-settings文件中使用此文本一样简单:

{
    "python_interpreter": "/Users/mc/anaconda/bin/python",
    "extra_paths":
    [
    "/Users/mc/workspaces/brg/brg_framework/libs/python",
    "/Users/mc/workspaces/brg/brg_packages/brg_fea"
    ]
}

当我尝试构建文件时,我立即从该python库中获取有关模块的ImportError(brg是〜/ brg_framework / libs / python包中的文件夹)。如果我要求构建的路径,我得到以下内容,但不是我的额外路径。

print sys.path
['/Users/mc/workspaces/BRG/brg_packages/brg_splines', '/Users/mc/anaconda/lib/python27.zip', '/Users/mc/anaconda/lib/python2.7', '/Users/mc/anaconda/lib/python2.7/plat-darwin', '/Users/mc/anaconda/lib/python2.7/plat-mac', '/Users/mc/anaconda/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/mc/anaconda/lib/python2.7/lib-tk', '/Users/mc/anaconda/lib/python2.7/lib-old', '/Users/mc/anaconda/lib/python2.7/lib-dynload', '/Users/mc/anaconda/lib/python2.7/site-packages', '/Users/mc/anaconda/lib/python2.7/site-packages/Sphinx-1.3.5-py2.7.egg', '/Users/mc/anaconda/lib/python2.7/site-packages/aeosa', '/Users/mc/anaconda/lib/python2.7/site-packages/setuptools-21.2.1-py2.7.egg']

ImportError: No module named brg.datastructures.network.network
[Finished in 0.0s with exit code 1]
[shell_cmd: python -u "/Users/mc/workspaces/BRG/brg_packages/brg_splines/splinenetwork.py"]
[dir: /Users/mc/workspaces/BRG/brg_packages/brg_splines]
[path: /Users/mc/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin]

是否以某种方式覆盖了Anaconda.sublime-settings文件? 如果重要的话,我正在运行OS X.

1 个答案:

答案 0 :(得分:0)

作为r-stein indicated,Anaconda中的"extra_paths"设置是用于自动完成和linting功能,而不是用于构建。如果您需要更改PYTHONPATH,则必须创建新的build system。选择 Tools → Build System → New Build System… ,删除打开的视图的内容,然后添加:

{
    "shell_cmd": "/Users/mc/anaconda/bin/python -u \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "env": {"PYTHONPATH": "/Users/mc/workspaces/brg/brg_framework/libs/python:/Users/mc/workspaces/brg/brg_packages/brg_fea"}
}

将文件另存为Packages/User/brg_Python.sublime-build(保存对话框应已在Packages/User中打开。现在,您可以选择 Tools → Build System → brg_Python 并使用