我是Mac的新用户。我正在尝试在Mac中使用python。所以,我使用了崇高的文本2。
我使用sublimeREPL:python来运行python。但我认为我有一些问题。
首先,Python的版本在终端OS X和sublime text2中是不同的。
在终端,
Python 2.7.11 (default, Feb 27 2016, 16:44:31)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
在崇高的文字中,
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
另外,当我使用sublimeREPL:python时,我收到如下错误信息。
SublimeREPL: obtaining sane environment failed in getenv()
Check console and 'getenv_command' setting
WARN: Falling back to SublimeText environment
我认为这是Windows中的一种路径问题。但我不知道如何解决它。我的Mac OS X El Capitan版本是10.11.3。
请给我一个建议。
提前致谢。
修改
当我运行sublimeREPL:python时,我添加了SublimeText控制台(View | Console)消息。
startup, version: 2221 osx x64 channel: stable
executable: /Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2
working dir: /
packages path: /Users/kims/Library/Application Support/Sublime Text 2/Packages
settings path: /Users/kims/Library/Application Support/Sublime Text 2/Settings
PackageSetup not required
catalogue loaded
found 6 files for base name Default.sublime-keymap
found 1 files for base name Default.sublime-mousemap
found 38 files for base name Main.sublime-menu
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/0_package_control_loader/00-package_control.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/0_package_control_loader/02-bz2.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/CSS/css_completions.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/comment.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/copy_path.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/delete_word.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/detect_indentation.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/duplicate_line.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/echo.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/exec.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/fold.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/font.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/goto_line.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/indentation.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/kill_ring.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/mark.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/new_templates.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/open_file_settings.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/open_in_browser.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/paragraph.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/save_on_focus_lost.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/scroll.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/set_unsaved_view_name.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/side_bar.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/sort.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/swap_line.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/switch_file.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/transform.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/transpose.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Default/trim_trailing_white_space.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Diff/diff.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/HTML/encode_html_entities.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/HTML/html_completions.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Package Control/1_reloader.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Package Control/2_bootstrap.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/Package Control/Package Control.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/SublimeREPL/__init__.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/SublimeREPL/completions.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/SublimeREPL/lang_integration.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/SublimeREPL/run_existing_command.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/SublimeREPL/sublimerepl.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/SublimeREPL/sublimerepl_build_system_hack.py
Reloading plugin /Users/kims/Library/Application Support/Sublime Text 2/Packages/SublimeREPL/text_transfer.py
plugin init time: 1.25108
loading bindings
loading pointer bindings
found 1 files for base name Default.sublime-theme
theme loaded
app ready
pre session restore time: 1.75546
using gamma: 1.9 (err: 99.6544)
startup cache, total files: 170 cache hits: 170
startup time: 1.9001 (package setup was not run)
loaded 837 snippets
Package Control: No updated packages
Traceback (most recent call last):
File "./repls/subprocess_repl.py", line 144, in getenv
AttributeError: 'module' object has no attribute 'check_output'
error: SublimeREPL: obtaining sane environment failed in getenv()
Check console and 'getenv_command' setting
WARN: Falling back to SublimeText environment
答案 0 :(得分:0)
您不应该使用与 Sublime
捆绑在一起的Python解释器来运行您的代码。它用于运行包(即Sublime文本的插件)。
如果你想在REPL中快速测试一些东西,只需在shell中运行 python
并开始攻击。
SublimeREPL将python与virutalenv
一起使用,因此您需要创建一个使用您喜欢的python
解释器:
virtualenv -p /path/to/python path-to-virtualenv
要查看哪个是默认python,请运行
which python
在您创建了virutalenv之后,您需要确保包使用它,方法是将其添加到您的包设置中(从命令面板中选择Preferences: SublimeREPL (User)
)并输入:
{
"python_virtualenv_paths": [
"path-to-your-newly-created-virtualenv",
],
}