pynput icon indicating copy to clipboard operation
pynput copied to clipboard

Cant from pynput.mouse import Button, Controller in compiler

Open waa8128 opened this issue 4 years ago • 2 comments

The code worked in cmd but failed in compiler: the error is: Traceback (most recent call last): File "C:\Users\THINK\Desktop\exp\monitor\pynput.py", line 13, in import pynput File "C:\Users\THINK\Desktop\exp\monitor\pynput.py", line 15, in from pynput.mouse import Button, Controller ModuleNotFoundError: No module named 'pynput.mouse'; 'pynput' is not a package

waa8128 avatar Jan 09 '21 15:01 waa8128

Thank you for your report.

What do you mean by compiler?

moses-palmer avatar Jan 21 '21 17:01 moses-palmer

I think it is the same problem I got right now.

Sitting in Pycharm and learning to use Pynput with the documentation.

This code doesn't work when running it through the Pycharm terminal, but works in the real command prompt on Windows 10

The Keyboard version works in the Pycharm terminal though:

`from pynput import mouse

def on_move(x, y): print('Pointer moved to {0}'.format((x, y)))

def on_click(x, y, button, pressed): print('{0} at {1}'.format('Pressed' if pressed else 'Released', (x, y))) if not pressed: # Stop listener return False

def on_scroll(x, y, dx, dy): print('Scrolled {0} at {1}'.format('down' if dy < 0 else 'up', (x, y)))

Collect events until released

with mouse.Listener( on_move=on_move, on_click=on_click, on_scroll=on_scroll) as listener: listener.join()`

qkum avatar Feb 13 '21 17:02 qkum