I am trying to do a python script and while the script is running in the background I want it to listen at some buttons, the problem is that I can't even this simple program to get to work, I get segmentation fault 11. When I run it I use sudo python3 prog.py.
import keyboard
keyboard.wait('esc')
print("test")
Couple of things:
You don't compile a Python program
The problem is that you don't have permission to access that memory, hence the segfault. The fix depends on your system, on my Mac I just changed the permissions of the terminal (so that it could control my computer).
Also, I just want to mention that a process in the background does not take in data from STDIN, so you may have a problem there depending on what you mean.
Related
I read the proposals but I dont found a answer.
How can I run a Octave .m-File from a python script in Linux?
Must I change the direction?
I want to run the Octave .m-File with functions in the background without gui.
I try it with the os module from python:
(INFO: The .m-File run without bugs in octave)
import os
os.system("octave-cli /home/myscripts/test.m")
If I run this in the python console in spyder, I get "0" as output.
Normaly It must be "1" if have no bugs or? Must I make the test.m file executable?
I'm totally baffled by this.. Trying to code a python script on my Debian Stretch system but after running a 4 lined script my mouse cursor would turn into a cross and blocking any click actions from working and forcing me to hard reset the system by holding the off button!
I tested a few times and found out that my script just needs to contain an import for it to break, nothing else - literally a one-lined:
import pxssh
And run
./bug.py
System broken. Mouse cursor looks like a cross and cannot click anywhere. Hard reset required.
I found someone else with what appears to be the exact same issue, there's an uploaded image of it but I don't know if it was python causing it for him/her. https://askubuntu.com/questions/918261/why-does-my-cursor-keep-changing-to-a-black-cross-and-how-do-i-revert-it
If I use my keyboard and re-run it again, I get this error:
import-im6.q16: unable to grab mouse `': Resource temporarily unavailable # error/xwindow.c/XSelectWindow/9182.
You're not running Python! You're accidentally running this as a shell script. Run it as
python bug.py
or include the shebang line:
#!/usr/bin/env python
Currently, you seem to be running a completely unrelated program named import, designed for screen capture.
This has just happened to me, and without this thread I would never have found the cause. I just would like to add that you can stop the 'import' program by running:
pkill -9 import
And that should fix everything.
I spend a lot of time running programs from python using the subprocess module. One of my scripts uses the check_call command to run a program from the command line around 600 times. Today I updated to Spyder 3 and when I run this script I get a pop up which looks like this
This stays for the duration of the program (a few seconds) then disappears but then another appears to replace it as my programs uses the check_call command again. This behavior is very disruptive as it means I can't just run a long program in the background on my machine whilst working on something else. Also this was never a problem on the old version of Spyder I had. Does anybody know how to turn this very annoying behavior off?
(Spyder dev here) If I'm not mistaken, now you need to pass the parameter shell=True to all subprocess commands you're using to avoid this problem.
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.
I wrote a small app and I am using pynotify to show some messages to the user.
It all works fine here in arch, but when I tested it in Ubuntu, the behaviour was very weird.
Because of the way Ubuntu shows notifications (as what seems to be a rip of of growl), I can't click on them, or interact with them in any way, for that matter.
The biggest problem, however, is that it only shows one notification at a time, and has to wait (a long time, by default) untill one of them goes away to show the next one.
Given the nature of the little app I'm writing (a simple monitor that runs a command every time a file is changed), the results must appear to the user in real time.
I have tried to set a small timeout with message.set_timeout(), but Ubuntu just seems to ignore it.
--
So, here is my question: Am I the only one to notice that? Am I doing something wrong?
If not, is there any way to change that behaviour in Ubuntu? Any workaround?
Thanks in advance for your time
Yes, Ubuntu 9.10 replaced upstream's notification-daemon with their own notify-osd, and generally made a mess of things.
You can ensure notification-daemon is installed (via whatever your favorite package manager front-end is) and use it in favor of notify-osd:
$ sudo mv /usr/share/dbus-1/services/org.freedesktop.Notifications.service /usr/share/dbus-1/services/org.freedesktop.Notifications.service.disabled
$ sudo mv /usr/share/dbus-1/services/org.freedesktop.Notifications.service.notify-osd /usr/share/dbus-1/services/org.freedesktop.Notifications.service
Unfortunately this will get overwritten whenever the package is updated... it's already using a dpkg-diversion so it's hard to re-divert it permanently.