Sublime Text 2:自定义PATH和PYTHONPATH [英] Sublime Text 2: custom PATH and PYTHONPATH

查看:227
本文介绍了Sublime Text 2:自定义PATH和PYTHONPATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是在/ usr / local / bin /
中安装python(2.7.2)的brew,但是,执行默认的系统python(2.7.1)代替 / usr / bin / ,这似乎是因为它不遵守任何bash PATH环境变量。
另外,它找不到我的模块,因为它们安装在$ code> /usr/local/lib/python:/usr/local/Cellar/python/2.7.2/lib/python2 .7 / site-packages 。



我一直在尝试使用 Python.sublime-settings ,但它不起作用:

  {
path:/ usr /本地/ bin:/ usr / bin:/ bin:/ usr / sbin:/ sbin,
env:[PYTHONPATH,/ usr / local / lib / python:/ usr / local / /python/2.7.2/lib/python2.7/site-packages],
cmd:[python,-u,$ file],
file_regex :^ [] *文件\(... *?)\,行([0-9] *),
selector:source.python
}

如何使Sublime Text遵守这些环境变量?

解决方案

env需要是一个JSON对象或字典,如果你愿意,像这样:

 env:
{
PYTHONPATH:/ usr / local / lib / python:/usr/local/Cellar/python/2.7.2/lib/python2。 7 / site-packages
},


I'm using brew which installs python (2.7.2) in /usr/local/bin/ However, the default system python (2.7.1) is executed instead at /usr/bin/, which seems to be because it doesn't obey any of the bash PATH environment variables. Also, it can't find my modules, as they are installed at /usr/local/lib/python:/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages.

I've been trying the following with Python.sublime-settings, but it doesn't work:

{
"path": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
"env": ["PYTHONPATH", "/usr/local/lib/python:/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages"],
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}

How can I make Sublime Text obey these environment variables?

解决方案

env needs to be a JSON object, or dictionary if you will, like this:

"env":
{
    "PYTHONPATH":"/usr/local/lib/python:/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages"
},

这篇关于Sublime Text 2:自定义PATH和PYTHONPATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆