This opens whenever I start writing code in a kernel..stack.imgur.com/GQPYA.png
Expected: print("hellooo")
i am unable to type in the kernel, there's no error message, since there's no code.
I tried doing this multiple times, by closing and starting it again, but same thing happens over and over again.
Nothing to worry you have just opened command palette, search for confirm restart kernel and click it , or simply press the esc you should be ready to go.
Related
FIXED IT BUT WONT LET ME DELETE
As described by the title, I am trying to run a pretty long script that closes immediately. It closes immediately without showing me the output.
Here is what I've tried:
I've attempted adding input('Press ENTER to exit') and it didn't work. I also tried doing that same command but replacing exit with close and putting exit () under it, as well as exit(0)).
I've also attempted opening it with python myfile.py and nothing. I've tried almost everything I could find.
I'm on Windows, I'm running the script directly from the file, I downloaded it and attempted to run (Sorry if this isn't clear I'm new to Python). The script is long so I don't know if it'd be useful putting it here, also it's kind of private stuff.
quit_control=input("Do you know to quit? press 'Y' and enter for quit.")
while quit_control!="Y":
quit_control=input("Do you know to quit? press 'Y' and enter for quit.")
This may be a really basic question but I am not clear how to proceed. I have started using python in datacamp courses but now moving to my own terminal is giving me some issues. When I open VS code and open the file I want to work the terminal does not allow me to write, it just appears a path, I tried to run a simple code but it does not run, basically happen anything. Do you know if I have to do something specific before start running the code to enable the terminal?
import matplotlib.pyplot as plt
year = [1950, 1970, 1990, 2010]
pop = [2.519, 3.692, 5.563, 6.972]
plot1 = plt.scatter(year, pop)
plt.show()
And this is what I see on the screen, below the path highlighted in yellow the terminal does not allow to write
I Appreciate any suggestion, Thanks
The terminal is working fine, but there is currently a program running in it!
You called Python to execute your clase.py file. So, all input/output you do in the terminal will now go to/come from your Python program that you just called, not your shell.
You can either wait for the program to be finished (you will get another prompt then) or press Ctrl+C to abort your program. Since your program looks like it's outputting a plot somewhere, I'd assume it opens a new window for that - in this case, the terminal will return to the prompt once that window is closed.
If you need a second terminal to do something else while the program is running in the first, you can click the "+" button to open a second terminal (you can switch using the dropdown), or the "split" button right next to the "+" to open the second one at the side.
I am new to debugging. I simply want to see how the variables change as I run the program. I want to see what my program does and how.
But when I try to run the debugger, it shows the message: "Variables are not available":
Position the cursor on a line in your code where you are interested to see your variables.
Press Ctrl-F8 to toggle a breakpoint.
Debug your code.
I am trying to run a program on a jupyter notebook that accepts user input, and I cannot figure out how to get it to read standard input. For example, if I run the code with shift-enter:
a = input()
print(a)
the cell indicates it is running, but does not accept input from me. How do I get it to accept input?
Use the raw_input() (for Python 2) or input() (for Python 3) methods.
Example code:
a = raw_input()
print(a)
Example notebook:
I came across the same problem, using the input in jupyternotebook, it blocks the execution and it does not work until restarting the program, so I added a print () after each input and my program is working.
Probably you hit Shift-Enter a second time without completing the first input with Enter, so the kernel was always waiting until the first command completed, before executing it again. If you use in the menu
"Kernel",
"Interrupt",
all active commands are stopped (including the second execution of the box) and the problem should be solved without restarting the computer (or the browser / the kernel).
You are doing it right, you ony have to restart the kernel (over the Run button)
use raw_input instead of input if you are using python 2 version. if u still getting same problem then,
click on kernel then "restart and run all"
and try to run the code again.
this will fix it.
I have an IPython notebook. I have a long-running loop that produces no output in one of the code blocks. It's not this, but imagine it was this:
for i in range(100):
time.sleep(2)
I started the code block running a while ago, and now I can't tell whether it's finished, or whether it's still running.
All the IPython status bar says at the top is Last Checkpoint: 23 minutes ago (autosaved). There's nothing in the browser tab to show whether it's running code, either.
I don't want to start the next block because I don't know if this block has finished.
And I don't want to stop the kernel and add print statements to this block, because if it's 80% of the way through, I don't want to kill it and restart it!
Is there anything in IPython - either the browser window or the console - that indicates what code is running right now?
You can see whether code still being executed or not in three places,
In the top right corner, there will small circle which stays solid till the execution of code completes.
Every cell will have cell number but when that cell being executed it will show * instead of a number
In chrome and firefox browsers tabs icon changes from notebook to a clock.
The block of code will have the line number indicator like this ln[*], which means that the block is running:
Edit 1:
There is a bug in Jupyter notebooks and Jupyter lab (formerly known as Ipython notebooks) where refreshing or reopening the notebook will not keep the previous output (which includes ln[*]): https://github.com/jupyter/jupyter/issues/83
Edit 2:
If you are willing to use a library to show if a cell is running (and its progress), I recommend tqdm to add progress bars:
ASCII Bar:
GUI Bar:
look to the right of ipython terminal, there is a circle. if the block is still running you would see a solid circle and when you hover it says "kernel busy"
if there is nothing running, you would see an empty circle and when you hover it says "kernel idle"
Also, in the browser tab (chrome in my case), you see the timer icon when a cell is executing. This is handy if you are in some other tab and want to check the execution status.
timer image