请教,PIP官网的代码报错
python吧
全部回复
仅看楼主
level 3
我用pip insnall pynput 安装了pynput 1.6.8 ,project interpreter里面也能看到pynput了,复制以下pypi官方代码到pycharm里面,运行报错ModuleNotFoundError: No module named 'pynput.mouse'; 'pynput' is not a package
代码就是官方的例子:
from pynput.mouse import Button, Controller
mouse = Controller()
# Read pointer position
print('The current pointer position is {0}'.format(
mouse.position))
# Set pointer position
mouse.position = (10, 20)
print('Now we have moved it to {0}'.format(
mouse.position))
# Move pointer relative to current position
mouse.move(5, -5)
# Press and release
mouse.press(Button.left)
mouse.release(Button.left)
# Double click; this is different from pressing and releasing
# twice on Mac OSX
mouse.click(Button.left, 2)
# Scroll two steps down
mouse.scroll(0, 2)
请问这是什么原因啊,是pynput没装好吗?
2020年07月20日 17点07分 1
吧务
level 12
报错讲得很清楚了,你是不是模块外面还套了个文件夹pynput
2020年07月21日 00点07分 2
不太明白,我新手,能详细说说吗?谢谢
2020年07月21日 10点07分
想用到pynput这个库里面控制鼠标和键盘的方法,只需要PIP install pynput就可以了,还是再下别的组件啊?比如win32API之类
2020年07月21日 10点07分
在终端PIP INSTALL PYNPUT时,包是放在PYTHON3.8文件夹下的SITE-PACKAGE里面的,是不是要把PYNPUT包放进项目文件夹里?
2020年07月21日 15点07分
1