只是在 python 脚本中写“导入"会破坏我的鼠标光标,强制进行硬重置

2022-01-24 00:00:00 python debian

问题描述

我对此完全感到困惑.. 尝试在我的 Debian Stretch 系统上编写 python 脚本,但在运行 4 行脚本后,我的鼠标光标会变成十字并阻止任何点击操作,并迫使我努力按住关闭按钮重置系统!

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

然后运行

./bug.py 

系统坏了.鼠标光标看起来像一个十字,不能点击任何地方.需要硬重置.

System broken. Mouse cursor looks like a cross and cannot click anywhere. Hard reset required.

我发现其他人似乎有完全相同的问题,有一张上传的图片,但我不知道是否是 python 为他/她造成的.https://askubuntu.com/questions/918261/why-does-my-cursor-keep-chang-to-a-black-cross-and-how-do-i-revert-it

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.


解决方案

你没有运行 Python!您不小心将其作为 shell 脚本运行.运行它

You're not running Python! You're accidentally running this as a shell script. Run it as

python bug.py

或包括 shebang 行:

or include the shebang line:

#!/usr/bin/env python

目前,您似乎正在运行一个 完全不相关的程序,名为 import,专为截屏而设计.

Currently, you seem to be running a completely unrelated program named import, designed for screen capture.

相关文章