1

Everytime I start the python within sublimeREPL package, it gives me the error,there has already been a branch of discussion of this error,and the offical document gives the following solution

    "If the binary is not in your system path and you can’t or won’t change that, tweak SublimeREPL configuration:"
{
...
"default_extend_env": {"PATH": "{PATH}:/home/myusername/bin"}
...
 } 

I have changed the path to where the python interpreter is installed,say

    {

"default_extend_env": {"PATH": "{PATH}:\\Python34"}

    }

But it seems not correct, so which path name should I enter, the python interpreter path or sublimeREPL's path? And how can I find the path?Thank you

MattDMo
  • 100,794
  • 21
  • 241
  • 231
zlqs1985
  • 509
  • 2
  • 8
  • 25

2 Answers2

8

You'll need to edit one of the SublimeREPL config files to point to C:\Python34\python.exe. First of all, though, you should add C:\Python34 to your system's PATH variable - google it if you don't know how. If that doesn't work (after restarting Sublime Text), do the following:

Open your Packages folder by selecting Preferences -> Browse Packages.... Once Packages opens in Windows Explorer, open the SublimeREPL folder, then the config folder, then the Python folder, then open Main.sublime-menu in Sublime (use JSON syntax highlighting). Now, anywhere you see a "cmd" option, inside the following brackets replace "python" with "c:/python34/python.exe" (remember to use forward slashes / as the path delimiters). So, this:

"cmd": ["python", "-u", "$file_basename"],

should be changed to:

"cmd": ["c:/python34/python.exe", "-u", "$file_basename"],

In the section with "caption": "Python - IPython", only alter the line in the "cmd" dict starting with "windows" (line 71). So, all in all, you should be altering lines 22, 39, 53, and 71. Save the file when you're done, restart Sublime, and SublimeREPL should now be working with Python 3.4

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • Thank you so much for your detailed answer I really hope it can work. However, after I follow your suggestion (simplely change cig file doesn't work and I replace the ` "python"` with `"C:/Python34/python.exe"` as you told) and restart the sublime text 2, but the problem remains and become `C:/Python34/python.exe: can't open file···`this time. As I said , I really love the editor and want to learn python interactively on it through sublimeREPL, but it seems I meet a cumbersome problem. – zlqs1985 Jan 29 '15 at 02:32
  • I think I may misunderstand something about this plugin. What I desire is a interactive environment, that I have interactive prompt >>> everytime I enter the environment and see the outcome when I tap in some commands, Aslo I can write a block of code and sent it to interpreter by a shortcut. Can my goals be achieved through sublimeREPL and how? – zlqs1985 Jan 29 '15 at 02:51
  • @zlqs1985 To start the Python interpreter, select **`Tools -> SublimeREPL -> Python -> Python`** and you should be all set. If you are trying to run code, make sure the file is saved first and the Python REPL is running, then select **`Tools -> SublimeREPL -> Eval in REPL`** and choose the option you want. – MattDMo Jan 29 '15 at 16:28
0

Another option is to solve this issue using symlinks. Because I am lazy and didn't want to figure out all of the places that I might need to change settings within Sublime, I just created a symbolic link between where Sublime REPL thought that the executable should be and where it actually was - that way, when Sublime REPL looks to where it thinks the executable will be the symbolic link will automatically point it in the right direction.

At least for me, this error was accompanied by a message saying where Sublime REPL had tried, unsuccessfully, to locate the python executable (in my case, Sublime REPL had tried finding it in /Users/Ohlrogge/anaconda/bin/). To find where the executable actually was, I used ran the following command from the terminal:

which python

This then gave me the directory the python executable is in (in this case it was, for me, /anaconda/bin/. Then, I just entered into the terminal:

ln -s /anaconda/bin/python /Users/Ohlrogge/anaconda/bin/python

in order to create the symbolic link. Note the general syntax for ln command, which will work in linux or osx, is:

ln -s [/path/to/original] [/path/to/symlink]

In Windows systems, it is similar, but the order of the arguments is reversed:

mklink [path\to\link] [path\to\original]

See here for more on linking in windows.

Michael Ohlrogge
  • 10,559
  • 5
  • 48
  • 76