Pycharm doesn't show pynput as package to install

221 Views Asked by At

My pycharm 2020-2.3 doesn't recognize pynput as a package for installation this is what it shows. I've been trying to get this to run.

import pynput
from pynput.mouse import Controller


def controlMouse():
     mouse = Controller()
     mouse.position = (10,20)

controlMouse()

But then i get this error message below.

ModuleNotFoundError: No module named 'pynput.mouse'; 'pynput' is not 
a package

it runs on other IDEs and pip says it's installed. Please help.

2

There are 2 best solutions below

0
On BEST ANSWER

Okay. i was able to fix the issue with pycharm recognizing libraries by trying two different things one was toggling 'Use Conda Package Manager from conda' off. see here under python intrepreter. I then searched for the package pynput which i was able to install. The other was renaming the file ('shouldn't have named it as pynput.py).

i also selected File > invalidate Caches/ restart > restart now. after i made these changes.

1
On

Looks like you might have a syntax error in the import.

"from pynput.mouse import Button, Controller" is from the documentation at https://pypi.org/project/pynput/

If that doesn't work, I would just try and uninstall pynput and reinstall For Python 3.6 this would be 'pip uninstall --user pynput' pip install pynput

''' pip install pynput Collecting pynput Downloading pynput-1.7.1-py2.py3-none-any.whl (99 kB) |████████████████████████████████| 99 kB 2.0 MB/s Collecting six Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) Installing collected packages: six, pynput Successfully installed pynput-1.7.1 six-1.15.0 '''