admin管理员组文章数量:1026979
I was writing code to automatically click the mouse,
zsh: illegal hardware instruction /Library/Frameworks/Python.framework/Versions/3.12/bin/python3
error.
I thought it might be a problem with the combination of Pynput and PyQt, so I added the following code
(when a button is clicked, the key pressed afterwards is displayed in the console).
The same error occurred, so I still think the combination is bad.
The screen starts up, but when I press a button, it crashes and throws an error.
The VSCode debugger does not say anything.
The environment is Mac OS Sonoma, Intel Mac.
The following is the source code.
from PyQt6.QtWidgets import QApplication, QWidget, QGridLayout, QLabel, QLineEdit, QPushButton
from pynput import keyboard
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("test")
grid = QGridLayout()
self.setLayout(grid)
self.testbut = QPushButton("テスト")
self.testbut.clicked.connect(self.function)
grid.addWidget(self.testbut, 0, 0)
def function(self):
listener = keyboard.Listener(on_press=self.on_press)
listener.start()
def on_press(self, key):
print(key.char)
qAp = QApplication(sys.argv)
mainwindow = Window()
mainwindow.show()
qAp.exec()
I was writing code to automatically click the mouse,
zsh: illegal hardware instruction /Library/Frameworks/Python.framework/Versions/3.12/bin/python3
error.
I thought it might be a problem with the combination of Pynput and PyQt, so I added the following code
(when a button is clicked, the key pressed afterwards is displayed in the console).
The same error occurred, so I still think the combination is bad.
The screen starts up, but when I press a button, it crashes and throws an error.
The VSCode debugger does not say anything.
The environment is Mac OS Sonoma, Intel Mac.
The following is the source code.
from PyQt6.QtWidgets import QApplication, QWidget, QGridLayout, QLabel, QLineEdit, QPushButton
from pynput import keyboard
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("test")
grid = QGridLayout()
self.setLayout(grid)
self.testbut = QPushButton("テスト")
self.testbut.clicked.connect(self.function)
grid.addWidget(self.testbut, 0, 0)
def function(self):
listener = keyboard.Listener(on_press=self.on_press)
listener.start()
def on_press(self, key):
print(key.char)
qAp = QApplication(sys.argv)
mainwindow = Window()
mainwindow.show()
qAp.exec()
本文标签: pythonillegal hardware instructionWhen pynput and PyQt are combinedStack Overflow
版权声明:本文标题:python - illegal hardware instruction : When pynput and PyQt are combined - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745654412a2161512.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论