What does "== RESTART <path> ==" in the IDLE Shell mean? - python

I have a simple script I wrote, and when trying to run it (F5) , I get this msg:
================== RESTART: C:\Users\***\Desktop\tst.py ==================
I restarted the shell, reopened the script, but still, the same msg appears.
I use python 3.5.1 and I tried to simplify the script as much as possible, but I still get this result. Now my script is only one line with a simple print(1) command and I still get this msg.
Was there something wrong with the shell installation?

I have a simple script I wrote, and when trying to run it (F5)
That's the hotkey for IDLE to run a file. It is not ordering to do anything. It's a log statement to explicitly declare that your namespace is being cleared and the file is going to be ran fresh again.
no, I didn't tell it to restart
But you did... You pressed F5

The same thing is happening with my shell. In the older versions, this does not happen. I've also noticed that when I press Python 3.5.2 Module Docs, I have my Internet browser open up and I see my directory being displayed onscreen. It looks like:
C:\Users\mycomputername\AppData\Local\Programs\Python\Python35-32\DLLs.
Is that suppose to happen? Is that secured? I don't know.
I've also found that this prints out whenever I "imported" something. So if I use an import command, and put it right before the line of my random name, it will print out that "RESTART" thing. It's always at the beginning. Or what it reads as the beginning.

CIsForCookies, my guess is that you don't actually have a complete script; maybe you have just a function definition and you haven't included a line to run that function. (I had this problem and then remembered to call the function I defined; the problem went away.)

You may have made the same mistake as me and ran a program and then you wonder why RESTART is all that shows up. My program was working perfectly I just did not print anything or ask for any input so it ran and was done with the program and nothing showed up.

Related

I think ive setup vscode the wrong way or not able to find out a few root reasons for a few errors

why is this error there in the terminal?
i was trying to run a simple file after saving it yet it wasnt able to locate the file in the directory as mentioned, hence was giving the following error.
The simplest way to fix this is to remove : at the end of second line. It is a typo which kind of destroys rest of the code.
Delete your current terminal, or Ctrl+Z and press Enter to exit the current python interactive mode.
When your terminal looks like this you can use the play button to run the code.
When your terminal looks like this, it means that you have opened the python interactive terminal, where you can directly type the code and run it, but you cannot run the command.
By the way, as others have said there is a bug in your code, you need to remove the semicolon at the end of the second line.

Python script closes without even running

I wrote a python script to run some simple tasks and this issue has been happening randomly at times.
Upon clicking on .py file, a cmd prompt window appears for a some microseconds and closes immediately without showing any text.
I thought this issue was because the code finished running too fast at first but the code doesnt actually run. I know this because the code involves sending a text message on discord through the requests module and I can see post-running that no text has been sent.
If it was the prior assumed issue, I would've just added some input for the program to recieve but my program has an infinite while loop in it which should be already enough to keep the cmd window open. Hence I dont understand what's causing this.
The last time it happened I somehow found a solution which I followed step by step and was able to resolve it but its happening again now and I cant find that solution again unfortunately. From vague memory, I recall the solution involved running some commands on windows terminal.
Are you double clicking the .py file? If so, it may not work in some situations. What you should do is open up your cmd and type the following.
C:\Users\Admin> python filename.py
You can replace filename with your file's name.
If you are using Mac or any Apple devices, you will need to replace python with python3.

PyCharm Terminal does not print any output

I'm completely new to Python and have downloaded the PyCharm IDE. I made a first little program that simply prints the given arguments:
import sys
print("Start")
for arg in sys.argv:
print(arg)
print("End")
Now I am trying to execute this program and pass arguments through the IDE. I have found the Run Configurations editor, but I don't want to set some fixed arguments on every launch, I want to play around and call the script with different arguments.
I then saw the "Terminal" in PyCharm, and thought I can call the script from there passing the arguments. However when I do that, I just get nothing. It doesn't print anything in Terminal. It only prints in the "Run" Tab, but also doesn't seem to take my passed arguments.
Somewhere on the internet I found someone suggesting to enable "Emulate Terminal in output console" in the Run Configurations. I did that but nothing changed.
So my question in short: What do I have to do in PyCharm to be able to quickly call a program with arguments and get output from the program directly within the Terminal/Shell/whatever-it-might-be where I ran the program from? I can't imagine that you would have to go through the Run Configurations everytime you want to call a script and pass something new.
Thanks!
Well, I found out why it didn't work. I just ran the script entering the script's name, i.e.:
test.py
however it needs to be run as:
python test.py
The reason I didn't realize this earlier is that running just test.py doesn't give any error like "unknown command" or so. Not even on windows cmd. So I'm not quite sure what the computer is doing when executing the script just with name. Anyways, running it with python program explicitly works now, also in PyCharm Terminal.

python syntax error with the version 2.5 any idea how to fix it?

first i tried to run it by pressing F5. it said the syntax error is in the first line. i tried running the program from the command line but it said the same thing. any idea what's wrong or how to fix it ?
F5 runs the script in the current window, but the current window doesn't display a script: it displays an interactive interpreter (also known as a REPL: Read, Evaluate, Print Loop).
In this window, you simply type valid Python statements, and they execute immediately. There is not way, or need, to run the contents of the window.

A python 3.5 script not printing results in windows command shell or powershell, only in the interpreter

I'm trying out some data science tutorials with python and can't get print to, well, print! when I run a .py in windows command shell or powershell. Print does work when I use the interpreter, but I have to type it in line by line (I'm not seeing how to run a .py as a file in the interpreter). I'm attaching snips of the file, and a snip of me running in the interpreter. I tried to attach snips of what happens when I run in command shell and powershell, but apparently I need at least 10 reputation points before I can post more than 2 links. Admittedly, those snips weren't interesting; there is no error and nothing printed. It just runs and returns to the prompt.
Also, as a test, I saved a .py file that simply does print ("Hello") and it does print correctly in windows command prompt and powershell.
Thanks in advance for any help!
Casie
PY script
Snip From Python Shell
Is that image from the IDLE console? To run the script you are editing, use menu Run > Run Module, or F5. Every python GUIs has an equivalent feature.
To run an arbitrary script from inside the commandline interpreter, say mywork.py: As long as it's in the working directory that you were in when you started the interpreter, you run it (once) by typing import mywork. (As you can see, its name must be a python identifier.)
Edit: You'd get to the bottom of this a lot quicker if you'd put print("Hello, world") in a script by itself and run it. From over here it looks like it would print just fine, proving there's nothing wrong with your python interpreter.
Your script has a bug, though: As soon as you enter the function random_kid(), you leave it again since you return a value on the first line. All those print statements are never executed. Why you think it works differently with %run I can't say, but for sure this function cannot print any output.

Categories

Resources