0
votes

I'm the new user in Mac.I'm trying to use python in the Mac. So, I use the sublime text 2 for this.

I use sublimeREPL:python to run python. but I think that I have some problems.

First of all, the version of Python is different in the terminal OS X and sublime text2.

In terminal,

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.

In sublime text,

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.

Also, when I use the sublimeREPL:python, I got an error message like below.

SublimeREPL: obtaining sane environment failed in getenv()
Check console and 'getenv_command' setting 
WARN: Falling back to SublimeText environment

I think that this is kind of path problem in Windows. but I have no idea how to fix it. My Mac OS X El Capitan version is 10.11.3.

Please, give me an advice.

Thanks in advance.

EDIT.

I add the SublimeText console (View|Console) message when I ran the sublimeREPL:python.

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
1
Can you open the SublimeText console (View|Console) and find the exception that should be printed there when SublimeREPL launches? - ig0774
I add the message when I launched the SublimeREPL. - kmangyo
Seems to be a known bug. There's this trick you could try. You may also want to change the "default_extend_env" (in your SublimeREPL.sublime-settings) to "{PATH}:/usr/local/bin" so it picks up on the Python you have installed there (I assume homebrew?) - ig0774

1 Answers

0
votes

You shouldn't be using the Python interpreter that is bundled with Sublime to run your code. It is used for running packages (i.e. plugins for Sublime text).

If you want to test something quick inside a REPL, just run python in a shell and start hacking.

SublimeREPL uses python with virutalenv, so you need to create one that uses the python interpreter you'd like:

virtualenv -p /path/to/python path-to-virtualenv

To see which is your default python, run

which python

After you've created your virutalenv, you need to make sure the package is using it by adding this to your package settings (choose Preferences: SublimeREPL (User) from the command palette) and enter:

{
    "python_virtualenv_paths": [
        "path-to-your-newly-created-virtualenv",
    ],
}