When i choose in REPL, EVAL or TRANSFER i have the following error running a py:
Cannot find REPL for 'python'
I use python 3, and reading other post i make this changes to use in sublime text 3
1.Create a file name: Python3.sublime.build with the following code:
{
"path": "/Library/Frameworks/Python.framework/Versions/3.3/bin/",
"cmd": ["python3.3", "-u", "$file"],
"env":{},
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
Then i have the option to build a Python3 System
2.In settings in sublime REPL - Default i put this:
"default_extend_env": {"PATH": "/Library/Frameworks/Python.framework/Versions/3.3/bin/python3:{PATH}"},
and change the file Main.sublime-menu in located in Packages/SublimeREPL/config/Python with this:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{"caption": "Python",
"id": "Python",
"children":[
{"command": "repl_open",
"caption": "Python 3",
"id": "repl_python3",
"mnemonic": "p",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["/Library/Frameworks/Python.framework/Versions/3.3/bin/python3", "-i", "-u"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
},
{"command": "repl_open",
"caption": "Python 3 - IPython",
"id": "repl_python_ipython3",
"mnemonic": "p",
"args": {
"type": "subprocess",
"encoding": "utf8",
"autocomplete_server": true,
"cmd": {
"osx": ["/Library/Frameworks/Python.framework/Versions/3.3/bin/python3", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
"linux": ["/Library/Frameworks/Python.framework/Versions/3.3/bin/python3", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
"windows": ["/Library/Frameworks/Python.framework/Versions/3.3/bin/python3", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"]
},
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {
"PYTHONIOENCODING": "utf-8",
"SUBLIMEREPL_EDITOR": "$editor"
}
}
}
]}
]
}]
}
]
I think there's must be an easy way to refer python 3 but i don't find it or not find clear, when i choose in Tools, SublimeREPL, Python and Python 3 it open a new tab with python 3
Set Layout to "2 Rows" under View Menu.
Select "SublimeREPL:Python" from the Command Palette under Tools.
~Morgan (very new at this)
"https://superuser.com/questions/755320/sublime-text-cant-find-interpreters-for-sublimerepl"
Was the deal/fix on my side. ** REPL needs to be open first. . . . **
Dunno if its the same for others, but this small detail was the key for me.
lol.
Hope that helps
Related
I have an url in a test.txt file, and i want to use it in launch.json. I try many things without success, like setting a var in a task but it is impossible to use it in launch.json according what I've read (is it exact ?).
Exemple of code in launch.json I've tested, doesn't work (I am on macOS), I get the error "command shell not found" in VSCode when I launch the debugger (F5):
{
"inputs": [
{
"id": "DEBUG_URI",
"type": "command",
"command": "shell",
///"command": "cat test.txt",
"args": {
"command": "cat test.txt"
}
}
],
"version": "0.2.0",
"configurations": [
{
"name": "attach",
"request": "attach",
"type": "dart",
"preLaunchTask": "test.txt generator",
"observatoryUri": "${input:DEBUG_URI}"
}
]}
I've also tested "shellCommand.execute" (exemple here) instead of "shell" but it doesn't work...
thanks,
the "shellCommand.execute" comes from Tasks Shell Input extension, with this it works !! :
"inputs": [
{
"id": "DEBUG_URI",
"type": "command",
"command": "shellCommand.execute",
"args": {
"command": "cat test.txt",
"useFirstResult": "true",
}
}
],
"version": "0.2.0",
"configurations": [
{
"name": "attach",
"request": "attach",
"type": "dart",
"preLaunchTask": "test.txt generator",
"observatoryUri": "${input:DEBUG_URI}"
}
]}
with "useFirstResult": "true" you can avoid VSCode prompt
I'm trying to launch multiple programs that need to talk to each other in the debugger in VS Code and created a launch.json with a compound that launches each of the executables. The programs launch simultaneously and all try to connect to the host at the same time. Is there any way in VS Code to explicitly set some sort of time delay between launch of each of the executables, say 250ms or so?
{
"version": "0.2.0",
"configurations": [
{
"name": "Host",
"type": "cppdbg",
"request": "launch",
"program": "/home/user/build/bin/host",
"args": [],
"stopAtEntry": false,
"cwd": "/home/user/build/bin",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
},
{
"name": "Node A",
"type": "cppdbg",
"request": "launch",
"program": "/home/user/build/bin/Node_A",
"args": ["ArgA", "ArgB", "ArgC"],
"stopAtEntry": false,
"cwd": "/home/user/build/bin",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
},
{
"name": "Node B",
"type": "cppdbg",
"request": "launch",
"program": "/home/user/build/bin/Node_B",
"args": ["ArgA", "ArgB", "ArgC"],
"stopAtEntry": false,
"cwd": "/home/user/build/bin",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
}
],
"compounds": [
{
"name": "System",
"configurations": ["Host", "Node A", "Node B"]
}
]
}
Yes, you can add a prelaunch task which will sleep for x seconds.
So say you have a client and server on Node.js and the server db connection takes longer to load this causes problems with the client.
Delaying the client debugger on vscode would work like this on a Mac OS X
First create a task in the same folder as the launch.json file called tasks.json which will build out a shell command before launching the client.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Sleepdelay",
"type": "shell",
"command": "sleep 6",
"windows": {
"command": "ping 127.0.0.1 -n 6 > nul"
},
"group": "none",
"presentation": {
"reveal": "silent",
"panel": "new"
}
}
]
}
Add the following pretask to your launch.json file now to call the task
{
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Client",
"url": "http://localhost:9090",
"webRoot": "${workspaceFolder}/client/src",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/*"
},
"preLaunchTask": "Sleepdelay"
//"runtimeExecutable": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
{
"type": "node",
"request": "launch",
"name": "Server",
"program": "${workspaceFolder}/server/server.js",
"envFile": "${workspaceFolder}/server/.env",
"cwd": "${workspaceFolder}/server/"
}
],
"compounds": [
{
"name": "Server/Client",
"configurations": ["Server", "Client"]
}
]
}
The sleep command is available on Linux and MAC OS X. For Windows just use this hack in place of it:
ping 127.0.0.1 -n 6 > nul
Now you have a simple method to delay the launch of the client before the server.
Complementing Jason's answer
I was getting Error
OpenError: (:) [Out-File], NotSupportedException FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
On Windows (PowerShell Terminal), and have to change the ping hack command from:
"ping 127.0.0.1 -n 6 > nul"
to:
"ping 127.0.0.1 -n 6 > $null"
I want to ask how to debug a simple hello world output from a C++ file, on the launch file I have to put the executable but I have only created a C++ file, how to compile it, I have tried everything, please help.
{
"version": "0.1.0",
"command": "g++",
"isShellCommand": true,
// compiles and links with debugger information
"args": ["-g", "-o", "main.exe", "main.cpp"],
// without debugger information
// "args": ["-o", "hello.exe", "hello.cpp"],
"showOutput": "always"
}
Pretty old question but here's a clear explanation for anyone in future.
Issue is that the debugger was looking for a.exe but your build file will probably be named different.
Changing the values of program variable to "${workspaceFolder}\\${fileBasenameNoExtension}.exe" will fix this issue. This should be in the tasks.json and the launch.json.
This env variable takes care that the right name is substituted. Now set a breakpoint and press f5.
Further details here and here.
Here's a full preview of a working launch.json
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:\\MinGw\\bin",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
And a full preview of tasks.json.
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
NOTE: As explained here and here, you might want to set "externalConsole": true if your code needs input from user.
I'm asking because I don't know if it is possible.
But, I'm using VSCode to run a few makefiles.
My tasks.json:
{
"version": "0.1.0",
"command": "sh",
"args": ["-c"],
"isShellCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"tasks": [
{
"taskName": "CTRL + SHIFT _ B",
"isBuildCommand": true,
"args": ["$make run-db"]
},
{
"taskName": "run",
"args": ["make -C ${fileDirname} run;"]
},
{
"taskName": "install",
"args": ["make -C ${fileDirname} install;"]
},
{
"taskName": "test",
"args": ["make -C ${fileDirname} test;"]
}
]
}
I'd like to know If it is possible to create just one run make line, instead of creating one method for each task in my makefile, I just pass the extra argumment in the vscode command pallet(EX: ctrl+p task make install)
{
"taskName": "make",
"args": ["make -C ${fileDirname} $Method;"]
},
you can probably use environment variable
"env": {
"NODE_ENV": "development"
},
as in this exemple
I am new to Sublime Text 2 on Mac OS.
I installed the package SublimeREPL.
Is it possible to create a keyboard shortcut to run the file with SublimeREPL?
More precisely, here is a screenshot. I want to avoid going through this menu and run quickly with a keyboard shortcut.
You can set a keyboard shortcut for the command in your screenshot using Sublime key-bindings.
Open Sublime.
Go to Preferences > Key Bindings - User
Add these lines to the opened file between brackets:
{ "keys": ["ctrl+alt+b"], "command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}}
Save it.
It's done! You can type any key-combinations instead of "ctrl+alt+b", but make sure it's not reserved by Sublime itself (check in Preferences > Key Bindings - Default)
You can set keyboard shortcuts for any menu item that you can select, in any app.
Go to System Preferences → Keyboard → Shortcuts → App Shortcuts
Click the + to add a new shortcut.
Set the Application to Sublime Text.app, the Menu Title to the exact name of the menu option, and choose a Keyboard Shortcut.
Click Add.
I found that I lost the keybinding to the installed sublimeREPL, so I had to find how to get it back, since it is a time saving indispensable for me. I used it also on a pc that had not sublime Repl and worked for both. This worked for me in 2019, version 3.2
in preferences / keybinding (after you installed package control and sublimeREPL). I made this video too.
[
{"keys": ["ctrl+b"], "command": "repl_open",
"caption": "Python - RUN current file",
"id": "repl_python_run",
"mnemonic": "d",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["C:/Users/giova/AppData/Local/Programs/Python/Python37-32/python.exe", "-u", "-i", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}}
]
p.s.: change the location of the python.exe as it is stored in your pc.
You can also do this:
[
{"keys": ["ctrl+b"], "command": "repl_open",
"caption": "Python - RUN current file",
"id": "repl_python_run",
"mnemonic": "s",
"args": {
"extend_env": {"PYTHONIOENCODING": "utf-8"},
"cmd": ["py", "-u", "-i", "$file_basename",],
"type": "subprocess",
"encoding": "utf8",
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"view_id": "*REPL* [python]",
}}
]
To use different version of python, you can type py -2.7 for example, if you have them installed.
You can also use 'python' in the cmd list.
To see where the location of python is, you can import sys and look at sys.path from python itself. You can also add "-m", "-pdb" to do the debugging, using another key combination maybe.
This works again in 3.2
[
{ "keys": ["ctrl+b"], "command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}}
]
Go to Preferences -> Key Bindings, and write this in the window "Sublime-keymap --User"
[
{
"keys": ["ctrl+alt+b"],
"command": "repl_open",
"args": {
"cmd": ["python", "-u", "-i", "$file_basename"],
"cwd": "$file_path",
"encoding": "utf8",
"extend_env": {"PYTHONIOENCODING": "utf-8"},
"external_id": "python",
"syntax": "Packages/Python/Python.tmLanguage",
"type": "subprocess"
}
}]
i have an addition to Romina's answer,
i used her code, but it opens with Python default version, in my case (Linux Mint) it was Python 2.7,
so if you have that trouble just change her code with this:
[
{
"keys": ["ctrl+alt+b"],
"command": "repl_open",
"args": {
"cmd": ["python3", "-u", "-i", "$file_basename"],
"cwd": "$file_path",
"encoding": "utf8",
"extend_env": {"PYTHONIOENCODING": "utf-8"},
"external_id": "python3",
"syntax": "Packages/Python/Python.tmLanguage",
"type": "subprocess"
}
}]
And it works with Python 3 (if you have it installed of course)
tq, add debug
{ "keys": ["ctrl+b"], "command": "run_existing_window_command", "args":
{
"id": "repl_python_pdb",
"file": "config/Python/Main.sublime-menu"
}
},