Sublime2 и SublimeREPL

Использование Windows 7, Python 3.2 и Sublime Text 2

Я выполнил все инструкции по установке SublimeREPL, и когда я перехожу к Tools -> SublimeREPL -> Python -> Python, я получаю сообщение об ошибке: «WindowsError (2, «Система не может найти указанный файл».»). Я пошел в FAQ и добавил следующее (точно так же, как указано) к предпочтениям пользователя:

{
 ...
"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

}

Я пытаюсь оценить выбранный код в Sublime2 с помощью Python.

Это то, что я добавил в пользовательский файл (SublimeREPL.sublime-settings — User). Кроме того, что я добавил, в файле больше ничего нет.


person CJ12    schedule 22.01.2014    source источник
comment
Вы получаете сообщение об ошибке Ошибка при попытке проанализировать настройку... когда вы сохраняете скрипт Python или файл пользовательских настроек?   -  person Ashoka Lella    schedule 22.01.2014
comment
Пожалуйста, отредактируйте свой вопрос и опубликуйте весь файл SublimeREPL.sublime-settings, чтобы мы могли увидеть, в чем может быть ошибка.   -  person MattDMo    schedule 22.01.2014
comment
@AshokaLella Я понимаю, что сохраняю пользовательский файл   -  person CJ12    schedule 23.01.2014
comment
Добавлен пример @MattDMo   -  person CJ12    schedule 23.01.2014


Ответы (1)


Sublime REPL по умолчанию выбирает python из системного пути Windows. Вы можете установить этот путь, следуя этому

Если вы хотите внести изменения в SublimeREPL.sublime-settings, вам нужно изменить строку на

"default_extend_env": {"PATH":"{PATH};c:\\Python32"},
  1. Поскольку вы находитесь в Windows, вам нужно сохранить символ '\' от экранирования с помощью '\\'
  2. *SublimeREPL.sublime-settings — это файл JSON, поэтому он ожидает ',' в конце
  3. Часть "{PATH};" является необязательной. Это позволяет вам добавить путь Python к существующему пути вместо его переопределения.
person Ashoka Lella    schedule 23.01.2014
comment
Когда я запускаю R, происходит то же самое, значит ли это, что мне нужно каждый раз вручную переключать путь? - person CJ12; 23.01.2014
comment
вам нужно изменить {"PATH":"{PATH};c:\\Python32"} на {"PATH":"{PATH};c:\\Python32;c:\\path\\to\\R"} - person Ashoka Lella; 23.01.2014