【问题标题】:Sublime2 and SublimeREPLSublime2 和 SublimeREPL
【发布时间】:2014-02-12 22:35:50
【问题描述】:

使用 Windows 7、Python 3.2 和 Sublime Text 2

我查看了安装 SublimeREPL 的所有说明,当我转到 Tools -> SublimeREPL -> Python -> Python 时出现错误:“WindowsError(2, '系统找不到指定的文件。')。我去了常见问题解答并添加以下(完全按照说明)到用户偏好:

{
 ...
"default_extend_env": {"PATH": "C:/Python32"}
 ...
}`

当我尝试保存文件时,我收到另一个错误:“尝试解析设置时出错:预期值在...”,它指向 SublimeREPL 文件。

整个文件是安装附带的通用版本:

{
// default_extend_env are used to augment any environment variables
// that should be visible for all subprocess repls launched within
// SublimeREPL. This is a very good place to add PATH extension
// once "PATH": "{PATH}:/home/username/mylocalinstalls/bin" or whatever
"default_extend_env": {},

// Specify whether to move repls to a different Sublime Text group (frame)
// immediately on opening. Setting this to true will simply move it to
// the 'next' group from the one that was in focus when it was opened
// (one down with row layout, one to the right with column and grid
// layout). Alternatively, you can set this to the index of the group in
// which you want all repls to be opened (index 0 being the top-left group).
// Activating this option will NOT automatically change your layout/create
// a new group if it isn't open.
"open_repl_in_group": true,

// Persistent history is stored per REPL external_id, it means that all python
// REPLS will share history. If you wish you can disable history altogether
"persistent_history_enabled": true,

// By default SublimeREPL leaves REPL view open once the underlying subprocess
// dies or closes connection. This is useful when the process dies for an unexpected
// reason as it allows you to inspect it output. If you want. Setting this
// to true will cause SublimreREPL to close view once the process died.
"view_auto_close": false,

// Some terminals output ascii color codes which are not currently supported
// enable this option to filter them out.
"filter_ascii_color_codes": true,

// Where to look for python virtualenvs
"python_virtualenv_paths": [
    "~/.virtualenvs",  // virtualenvwrapper
    "~/.venv"  // venv.bash https://github.com/wuub/venv
],

// Use arrows for history navigation instead of Alt+[P|N]/Ctrl+[P|N]
"history_arrows": true,

// standard sublime view settings that will be overwritten on each repl view
// this has to be customized as a whole dictionary
"repl_view_settings": {
    "translate_tabs_to_spaces": false,
    "auto_indent": false,
    "smart_indent": false,
    "spell_check": false,
    "indent_subsequent_lines": false,
    "detect_indentation": false,
    "auto_complete": true,
    "line_numbers": false,
    "gutter": false
},

// this settings exposes additional variables in repl config files, especially
// those related to sublime projects that are not available through standard API
// WARNING: this will switch your build system back to Automatic each time a REPL
// is started so beware!
"use_build_system_hack": false,

// IP address used to setup autocomplete server in sublimerepl.
// changing this is usefull when you want to exclude one address
// from proxychains/tsocks routing
"autocomplete_server_ip": "127.0.0.1",

// Mapping is used, when external_id of REPL does not match
// source.[xxx] scope of syntax definition used to highlight
// files from which text is being transfered. For example octave
// repls use source.matlab syntax files and w/o this mapping text transfer
// will not work
"external_id_mapping": {
    "octave": "matlab"
},

// If set to true, SublimeREPL will try to append evaluated code to repl
// output before evaluation (e.g. Ctrl+, f)
"show_transferred_text": false

}

我正在尝试使用 Python 评估 Sublime2 中的选定代码。

以上是我添加到用户文件(SublimeREPL.sublime-settings - User)的内容。除了我添加的内容之外,文件中没有其他内容。

【问题讨论】:

  • 您在保存 python 脚本或用户首选项文件时是否收到错误“尝试解析设置时出错...”?
  • edit您的问题并发布您的整个SublimeREPL.sublime-settings文件,以便我们查看错误可能是什么。
  • @AshokaLella 我知道它会保存用户文件
  • @MattDMo 添加示例

标签: python python-3.x sublimetext2 sublimerepl


【解决方案1】:

Sublime REPL 默认从 windows 系统路径获取 python。您可以通过关注this来设置此路径

如果您想在 SublimeREPL.sublime-settings 中进行更改,您需要将您的行更改为

"default_extend_env": {"PATH":"{PATH};c:\\Python32"},
  1. 由于您在 Windows 中,因此您需要使用 '\\' 保存 '\' 字符以防止转义
  2. *SublimeREPL.sublime-settings 是一个 JSON 文件,因此它的结尾应为“,”
  3. "{PATH};" 部分是可选的。它允许您将 python 路径添加到现有路径而不是覆盖它。

【讨论】:

  • 当我运行 R 时会发生同样的事情,这是否意味着我每次都必须手动切换路径?
  • 你需要将{"PATH":"{PATH};c:\\Python32"}修改为{"PATH":"{PATH};c:\\Python32;c:\\path\\to\\R"}
猜你喜欢
  • 2015-04-24
  • 2013-02-25
  • 1970-01-01
  • 2014-02-10
  • 2014-07-16
  • 2013-03-16
  • 2015-01-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多