“ No such file or directory” error happens when start SublimeREPL -python

Deadly 提交于 2019-12-02 12:53:06

问题


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


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/28198563/no-such-file-or-directory-error-happens-when-start-sublimerepl-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!