I have been learning python since last week weeks. I am using sublime text2 editor.
I have a simple file which prints some small text. How do I run this?
I have tried using ctrl+B but it only builds the file. How can I execute it?
You can accept user input in Sublime Text with SublimeREPL module. Install it via package control.
Related
My ultimate goal is to be able to execute a single or few lines of code in sublime text 3. I found this partial solution:
Build just one line in Sublime Text 3 - python
The highest rated answer provides a plugin code, but does not explain how to configure a plugin in sublime text editor. I created the code in a plugin file, but not clear how to activate. It says "Hint, make sure python is available on the sublime Text process"- if that means anything.
Any help would be great. Thanks!
Thank you if you are reading this and for help me.
I wrote a python script in sublime text 3, which uses a input function to take string and to display it using a print function.
I run the script with ctr + B, input command executed, now I write a string and hit enter. Cursor goes in next line and input function did not terminated.
Help me to solve this problem. Thank you.
Sublime Text does not support inputting data into a program .
How to solve this problem
Create a build system that first opens a terminal and then runs your program inside of the terminal
Use SublimeREPL to run your code in Sublime
Use Terminus in your build system; it allows you to create an actual interactive terminal directly within Sublime.
I would generally recommend Terminus for this; it's very easy
Quick Solution outside sublime :
can use separate cmd(Windows) or Terminal(Mac/Linux)
python name_file.py
Click the Sublime Text icon to launch it, or search for Sublime Text in
your system’s search bar and then launch it. Go to Tools Build System4
New Build System, which will open a new configuration file for you. Delete
what you see and enter the following:
{
"cmd": ["python3", "-u", "$file"],
}
I'm running a python script using Sublime Text 2. To run the script, I use command B--this works great until I want to explore some variable by typing it into the python interpreter, as the interpreter does not appear to be interactive. Is there any way to be able to input code into Sublime Text 2's interpreter in order to test ideas and code snippets before I add them to the main script?
I don't think sublime support it. I know you can use SublimeREPL when you need pass some users inputs.
I am a complete noob when it comes to programming. I just downloaded python and I will be using Notepad ++. I have saved a file to my desktop and the file name is test and changed the extension from .txt to .py
So when I go to Notepad ++ and create a program and save it, I go to the cmd prompt making sure I am in my desktop directory and type the following
python test.py
and it tells me that python is not recognized. Any help to fix this problem would be greatly appreciated.
First thing python is indent oriented programing language and it comes with its default editor called IDLE. So if you use notepad++ instead of IDLE it might gives you a syntax error. Second thing for executing python file from command prompt,you need to setup environment variable.Please see below link for setting up environment variable.
https://docs.python.org/2/using/windows.html
You can directly run your program in IDLE without using command prompt. So i would suggest you to use pythons built in editor (IDLE)
While editing a python script in the Sublime Text editor, I would like to run the script line by line, or block after block in the embedded interpreter.
Is there a convenient way how to do that? Perfect way for me would be:
select a few lines of code
hit a shortcut, which will run the selected code inside the interpreter
There are two choices I think, one can be using PdbSublimeTextSupport, available here: http://pypi.python.org/pypi/PdbSublimeTextSupport
Or you can try SublimeREPL, that can run Python code: https://github.com/wuub/SublimeREPL