Noticed this problem earlier this week: when I try running anything in Spyder, the script will usually execute fine the first time I run it, but if I try to run it again, the kernel hangs indefinitely after printing the standard "runfile('C:/Users..." statement. Ctrl-c doesn't work as an interrupt; the only fix I've found is to restart the kernel, then run some simple command such as a variable declaration (e.g. trying to run the script, restarting the kernel, then immediately retrying the script causes the restarted kernel to hang, but trying to run the script, restarting the kernel, running a simple command like x = 1, THEN retrying the script works - once). It seems like it might be an issue with my local directory, because anything in Spyder's default temp script runs fine. If I save the same script to a local directory, though, the problem persists, even for a one-line print("hello world") program. The problem is occurring with scripts that ran fine as of a week ago, and as far as I know I haven't updated Spyder or Windows in the interim. Has anybody run into anything like this before?
Related
I setup jupyter notebook on a server(Ubunutu) to run but every 20-30min the kernel just dies and tries to restart.
I already googeled but I don't use anaconda, I don't get any specific error and it doesn't look like a specific function which fails so most 'solutions' do not apply to my case it seems.
The code runs on cpu.
However the code does work on my local machine (windows) running on gpu.
I also run the notebook with --debugger but I don't get any error it just says reconnect out of nowhere :(
Has anyone of you encountered a similar problem? It is hard to figure out what is going on without having any error messages :/
Thanks for your help!
I tried to run a python program in VS Code. But my program didn't run. The terminal opened and a weird arrow was there in the terminal. This is the screenshot of that.
This is the weird arrow and the program is not running. Any ideas why this is happening and how to fix it?
Thanks in advance.
Firstly, the arrows are included in the default python IDE means that VScode ran the command to execute your code. Give your pc a restart. Now, let us check if python is working or not or VS code is having some trouble. Type the following command in cmd to execute the code-
python "$PATH"
Rember to replace $PATH to the path of the file i.e where your file is stored. For eg. I've my python files stored in D drive in a python folder, so I'll use-
python "D:\Python\Hello.py"
If this works, python is working fine and if not, try reinstalling python and check the box which says Add python to Path or Environment variables. Then open VS code try to run the program again. But click the button only once and be patient because clicking it multiple times causes execute the same command again and cause a problem. It's my personal experience. Wait 5 minutes. Not works. Don't worry, there's a problem with the run extension you are using. I'll recommend the Code runner by Jun han. I personally use it. Type this in the extension search box-
formulahendry.code-runner
Install it and then try again.
Kill the terminal, and retry. If not work, restart the VSCode.
I am running a script in PyCharm and using the Python 3 installation that is installed with ArcGIS Pro.
Every other time I run the code, it returns "exit code 246", but it is not clear to me what could be causing this.
If I close and reopen the program or restart my computer, I might be able to run the code, but it doesn't work consistently.
The issue doesn't happen consistently so I don't think it's an issue with the code itself.
I discovered the same problem. Problem went away when I did this
try:
import arcpy
except:
I wrote a python script that run an infinite loop and every half second checks if there are new files in a directory:
while True:
files = os.listdir(path_to_dir)
# do something
time.sleep(0.5)
The code runs on windows 10 in a cmd window and I need to make sure it will never stop.
A) I need to find a mechanism (or few mechanisms) that will restart the script in all possible scenarios that it might turn off (it is ok if the restart will happen only 2 minutes later...):
if the computer is restarting
if someone close the cmd windows
if the script end unexpectedly because of unhandle exception or memory leak (it is not suppose to happen...)
B) I want that once in a week, proactively,the script will be turn off and restart.
Any ideas?
Thanks!!
p.s. my first idea was that the python script will only check for new file, and the task scheduled will run it every second, but the minimum interval for task scheduler is 1 minute.
I think these answer all your questions:
Since your script runs on windows, you can use the Microsoft Task Scheduler (which is installed with Windows) to start your Python script when your computer starts up.
If you do not use the cmd window, you can change your Python script extention from .py to .pyw to run the script without a terminal window. A bit more on that here: Executing scripts.
For opening the script after an exception has happend, have a look at this blog post: How to Restart Python Script after Exception and Run it Forever.
To restart your script once a week, you can also use the Task Scheduler mentioned in answer 1. I think this post could help you with restarting your script: Start and stop a python task
I am trying to run a python script via cmd prompt on my work PC (Windows 7, Python 2.7). The script requires filepaths from different drives on my PC. I am correctly pulling all necessary filepaths and I press Enter to run the script but the script just hangs. The only thing that shows is a blinking underscore. I try to click the X to close the prompt but nothing happens.
I am not able to Ctrl+C out of the program either. I open up Task Manager and I am not able to End Task (nothing happens) or End Process (cmd.exe doesn't even show up in this tab). I also tried Start-->Run-->taskkill /im cmd.exe but nothing happens. The rest of my team has no problem with Python 2.7. The only way to get out of the frozen cmd is to hold down the power button. I do not want to have to keep going through this process especially since this is during work. I'm hoping someone will be able to help me out:
Any idea what's wrong with the version of Python I am using?
How am I able to kill cmd.exe so that I can continue normal work functions without having to hold down the power button and waiting 5-10 minutes to reboot my PC?
The filepaths I was pulling files from were through ClearCase directories. It turned out that I simply had to reinstall ClearCase. There must have been some configuration issue that was causing the cmd to hang and thus forcing a hard reboot. It's good to point out that I am no longer experiencing this problem and that nothing was wrong with the python scripts.