-1

I installed the pyinput package through the package manager(file>settings>project>project interpreter) in PyCharm and it seems to be working fine from inside the IDE, but when I try to run the program from the CMD, I am getting the

"ModuleNotFoundError: No module named 'pynput'" error.

I tried adding it's parent folder in the path like that

parent_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.pardir)
sys.path.append((parent_dir+"/venv/Lib/site_packages").replace("\\", "/"))`

but it doesn't seem to work. What should I be doing in this case?

bad_coder
  • 8,684
  • 19
  • 37
  • 59
Petros21
  • 43
  • 6
  • Could it be that you use a virtual environment (venv) inside PyCharm? – zanseb Apr 12 '21 at 18:27
  • You need to activate the venv on the CMD for the packages to be found. See [the documentation on activating the venv](https://docs.python.org/3/library/venv.html#creating-virtual-environments) – bad_coder Apr 12 '21 at 18:44
  • Oh ok thanks I had no idea about that. So you cant just specify from inside the program where the folder to include is? Man the imports-module-package system of python is horrendous. – Petros21 Apr 12 '21 at 20:09

1 Answers1

2

It looks from your question, as written so far, like you're trying to use a module named pyinput but your code is calling it pynput, which is missing an i. Did you make a typo in your code, or in your question? :)

sinback
  • 808
  • 5
  • 15