Sublime Text 3 Python Interactive Console? [duplicate] - python

This question already has answers here:
Can't send input to running program in Sublime Text
(5 answers)
Closed 6 years ago.
I have been using a lot of sublime text 3 to write python. However, whenever a program I make needs user input, nothing happens. For example:
number = input("What is your favorite number?: ")
print(number)
This simply gives me the input prompt in the console, but anything that I type is ignored. The
print(number)
is never run. Is there a way to use an interactive console for sublime text 3? I have heard of something called REPL that will do the job in ST2, but I want to use an interactive console for python3 in ST3.
As of now, I just run programs that need input from terminal. Sometimes I'll use Pycharm, but I'm still getting used to pycharm.

SublimeREPL works for python3. Their current builds are actually all tested against ST3.
https://github.com/wuub/SublimeREPL

Related

How can I run my Python file using PyCharm terminal? [duplicate]

This question already has answers here:
How to execute Python scripts in Windows?
(9 answers)
Closed 1 year ago.
I tried to update my PyCharm but it got corrupted so I had to reinstall the program, since doing so I lost my previous settings.
Before, I used to be able to enter a file name into the Terminal (Not Python Console) and the code would run.
E.g I have a file named code.py, I could enter 'code' and it would run and print the statement.
print("Hello World")
But now when I try this, the Terminal returns no print statement output and simply opens up the code.py tab on PyCharm. What settings do I need to change? I have included a screenshot.
Open the terminal and type:
python code.py
i hope you already know how to open a terminal in pycharm so after doing that simply run the command that you want to run your code with, in this case it will be:
python code.py

Half output shown in Sublime [duplicate]

This question already has answers here:
Can't send input to running program in Sublime Text
(5 answers)
Closed 7 months ago.
I wrote a factorial program in Sublime text editor. After executing the program using the shortcut key Ctrl + B only the first print statement is getting executed. However, I tried using the shortcut key Ctrl + Shift + B and the result is the same.
The problem is that proper execution is not achieved and I am unable to figure out the issue which is causing the problem.
Here is an image of the above-mentioned situation. As you can clearly see that I am following the conventions to execute the code. However, only the first line is executed.
Although I tried the same code in default Python IDLE I got the result. As such I don't think the code is wrong. Is it due to some IDE issue or have I not installed the sublime text editor properly.
Your code isn't wrong; the problem is that Sublime doesn't support interacting with a running program without extra work. Although it connects stdout and stderr to the output panel so that output your program generates can be displayed, it doesn't connect stdin to anything.
What you see is yourself typing 34 into the output panel, but your program doesn't see that and just sits in the background forever waiting for input that you can't provide until you kill it.
In order to run an interactive program like this from Sublime, you need to create your own sublime-build file that either opens an external terminal and runs the program there, or one that utilizes a package such as Terminus to open a terminal within Sublime and run the program there. Both of those require you to know what command you need to run in the terminal in order to run your program in order to set up the build.
An example of using Terminus for this task (using C and not Python, so you'd need to adapt it) can be found in this video on buffering and interactive builds in Sublime (disclaimer, I'm the author).

I get nothing when use input function on python 3.6 [duplicate]

This question already has answers here:
Can't send input to running program in Sublime Text
(5 answers)
Closed 3 years ago.
I am trying something very simple but my code just stuck or it is a problem with the print input function. So this is my code
variable = input("Enter something: ")
print(variable)
When I run my script e get nothing. This is the output:
Enter something: try
And it just stuck. Nothing is printed. I do not know what is the problem and do not think that there is a coding problem.
Sublime text 3 has some build problems with its command palette. I just tried this code with sublime and faced the same problem.
Use command prompt(if windows) or terminal(if linux) with following command:
python <filename>.py
Or open this file with python IDLE and use F5 key to run the script.

Is there anyway to run the python interpreter from sublime text 3? [duplicate]

This question already has answers here:
How do I run Python code from Sublime Text 2?
(16 answers)
Closed 6 years ago.
I want to be able to run the python intpreter from inside sublime text so I can run simple snippets of code. Is there any easy way of doing this? Or do I have to open it in another window?
try installing Terminal plugin and run python from sublime text
Yes its very simple by using this plugin. You can run other language interpreter too.
Sublime Repl
Install it using package control and set the settings according to documentation. After installation, you can access the repl by going to Tools -> command pallet. Type in sublimerepl, there you will find for python.

Execute Python in Sublime Text 3 [duplicate]

This question already has an answer here:
How do I run python from Sublime text 3?
(1 answer)
Closed 6 years ago.
How can I execute Python 2.7 code using Sublime Text 3 on Windows 10? When I use the shortcut Ctrl+B it says 'python' is not recognized as an internal or external command, operable program or batch file. I can't edit python.sublime-build because as far as I know it does not exist in Sublime Text 3.
EDIT: I see this question is a duplicate. I did not see the post when I searched up the topic for some reason.
You need to add python to your system path or if you already have there is a chance that
that in C:\Windows there is exe with python icon called "py" rename it to "python" and it should work fine.

Categories