My question is pretty simple. When I run a this piece of code, be it in VSCode, Terminal or Idle, Python stops responding. I can't find a solution for this anywhere.
cap = cv2.VideoCapture(0)
Does anyone know why this happens?
EDIT: People are saying that this code probably isn't the issue. I know that it is, as I ran it in the shell alone and got the exact same issue.
More info: I am on MacOS Big Sur Beta 4.
Related
Heyo all. I just got a raspberry pi 4 and I moved my code from my PC to the pi and when I ran and fixed it so it could run. I started to notice that it printed out more then it should. I looked it up but I couldn't find any help or reason why it does it. Code is
#!/usr/bin/python3
from os import system
system('cls')
print('heyo')
output is
I have found out if I add a sleep timer I no longer get that problem.
I found out what caused it that is why I did not have code from my main program but I never found out exactly why it does it nor how to fix it without sleeping.
Notes: originally wrote it on windows 10 on my main PC I ported it over to my PI on the raspberry PI OS lite (I assume it is a Linux base OS). I changed the "clear" command to "cls" cause I am used to it. I am using VS code via SSH to the file. I am also using SSH to start the program. I run the code as:
./main.py
I did chmod +x test.py I am using python version 3.6.7. I am sorry if this seems basic or I made it way to confusing or there is a super super simple way to fix it (besides time.sleep). Thank you all for any help/input. Have a good night or good day.
Edit: I did not change anything but now it works for some reason. I have no clue why or how but for some reason it does.
It was doing just fine, and then suddenly when I tried to run my tkinter program, the program didn't open and instead the python launcher rocket kept bouncing up and down in my dock doing nothing. My program doesn't seem to be the problem because other tkinter programs I made previously do not open as well as the one I'm working on right now.
I've searched up on the internet but I couldn't find any answers to my situation. Please help me get my program running. Thank you
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 am having this really annoying problem: when I try to debug in Spyder, the whole program gets stuck and I have to abort it. Yesterday it was working completely fine.
Any idea on how to fix it?
Thank you!
I am pretty new to Python and I have been pretty annoyed with this problem. I am not sure if this matters, but I run my .py file with Python 2.7.6 with python installed on my computer, not using it on any online thing or other program. Every time I come across an error, my program works fine until it comes to the error, but the window disappears right before I can possibly read whatever the error said it was... Anyways, I haven't been able to find out what is wrong with my programming, and I am tired of guessing and guessing what is wrong. How can I extend the time so I can read the error message? Or something like that? Thanks
You should run it from command window/terminal instead of double clicking on the file.
Yes, as #shortfellow said, running it from the terminal should work:
python your_file.py
Another tip that helps in Python, if you are having a hard time with errors, is to use iPython for debugging/testing code on the spot. You can give it a try.
http://ipython.org/