What I've got: New copy of Yosemite, homebrew installation of python 2.7, Sublime Text 2 with the following packages: LaTex tools, Package Control, Rbox, and SublimeREPL. I downloaded package feedparser with Pip.
I'm new to python (and any coding beyond R) and I'm trying to set up a good workflow with Sublime Text 2. For some reason, when I try and load feedparser in the sublime REPL python window, I get "import error, no module named feedparser".
However, I can get the packaged to load from python in the terminal.
which python
in terminal I get back usr/local/bin/python
which is where homebrew puts python.
I have a limited understanding of this stuff, but I'm assuming its because REPL is using the old version of python that comes with OSX.
I tried changing the environment variable in the Python.sublime-build file according to this post (first answer):
Sublime Text 2: custom PATH and PYTHONPATH
Yet, it still does not work. Maybe I did it wrong? I'm not sure.
With the number of people using Sublime text and Python I know that this must get dealt with all of the time. I've lots of posts with people suggesting many different things and I'm fairly lost.
Thanks.
You can add a new menu item to Tools -> SublimeREPL -> Python
. First, open your Packages/User
directory by selecting Sublime Text 2 -> Preferences -> Browse Packages...
and opening the User
directory. Create a folder in User
called SublimeREPL
, inside that create a config
directory, and inside that create a Python
directory. Finally, make a new file in Sublime with JSON syntax and the following contents:
[
{
"id": "tools",
"children":
[
{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{
"caption": "Python",
"id": "Python",
"children":
[
{
"command": "repl_open",
"caption": "Python (Homebrew)",
"id": "repl_python",
"mnemonic": "p",
"args":
{
"type": "subprocess",
"encoding": "utf8",
"cmd": ["/usr/local/bin/python", "-i", "-u"],
"cwd": "/Users/williamrudisill/Development/python",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]
}
]
}
]
}
]
Save this file as Packages/User/SublimeREPL/config/Python/Main.sublime-menu
. Make sure you edit the "cwd"
parameter to set the folder you'd like the interpreter to open in.
Now, if you open Tools -> SublimeREPL -> Python
there will be an item called Python (Homebrew)
that you can use to open an interpreter with /usr/local/bin/python
.