Skip to content

Instantly share code, notes, and snippets.

@sohocoke
Last active August 30, 2017 11:07
Show Gist options
  • Save sohocoke/7f7153ebf3f1e61a608a7824c927bb59 to your computer and use it in GitHub Desktop.
Save sohocoke/7f7153ebf3f1e61a608a7824c927bb59 to your computer and use it in GitHub Desktop.

Configuring Sublime Text 3 with pyenv

Context

Wanted to try out some Python NLP packages, found API discovery in Jupyter less than ideal.

Problem

Sublime Text 3 gave me a headache because it didn't pick up the default Python version I set using pyenv.

Solution

  • Ensure pyenv works and is set up to use your default Python version of choice.
  • Identify PATH elements inserted by Pyenv:
    user@host ~> echo $PATH
    /usr/local/opt/pyenv/shims:/usr/local/opt/pyenv/bin:/usr/local/opt/rbenv/shims:/usr/local/opt/rbenv/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin
    user@host ~> 
  • Add these elements to Sublime Text's user preferences:
    {
        "additional_path_items": [
            "/usr/local/opt/pyenv/shims",
            "/usr/local/opt/pyenv/bin",
            "~/.rbenv/shims",
            "~/.rbenv/bin",
            "~/.bin",
            "/usr/local/bin"
        ],
        ...
    }
  • Test correct version with some Python code in Sublime Text 3:
    import os
    
    os.system("python --version")
    # > Python 3.5.1
    # > 0
    Sublime Worksheet is handy for cases like this where you'd like to write and test out some code quickly without the burden of thinking about where to save the file, what to name the file etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment